generated from carpentries/workbench-template-md
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Still requires internal review and additional exercises/flow changes.
- Loading branch information
Showing
21 changed files
with
3,908 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,14 +59,21 @@ contact: '[email protected]' | |
|
||
# Order of episodes in your lesson | ||
episodes: | ||
- introduction.md | ||
- profiling-introduction.md | ||
- profiling-functions.md | ||
- profiling-lines.md | ||
- profiling-conclusion.md | ||
- optimisation-introduction.md | ||
- optimisation-use-latest.md | ||
- optimisation-memory.md | ||
- optimisation-list-tuple.md | ||
- optimisation-dict-set.md | ||
- optimisation-minimise-python.md | ||
- optimisation-conclusion.md | ||
|
||
# Information for Learners | ||
learners: | ||
- setup.md | ||
|
||
# Information for Instructors | ||
instructors: | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
Construct a graph demonstrating the number of re-allocations | ||
if growing a CPython List with append() | ||
""" | ||
t = 0 | ||
a = 0 | ||
x = range(1000000) | ||
|
||
allocs = [0 for x in range(1000000)] | ||
while t < 1000000: | ||
t += 1 | ||
t_old = t | ||
# https://github.com/python/cpython/blob/a571a2fd3fdaeafdfd71f3d80ed5a3b22b63d0f7/Objects/listobject.c#L74 | ||
t = t + (t >> 3) + 6 | ||
a+=1 | ||
for k in range(t_old, t+1): | ||
if k < len(allocs): | ||
allocs[k] = a | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
plt.plot(x, allocs) | ||
|
||
plt.xlabel("Appends") | ||
plt.ylabel("Resizes") | ||
#plt.ticklabel_format(style='plain') | ||
#plt.xscale('symlog') | ||
plt.savefig('cpython_list_allocations.png') | ||
plt.show() |
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Construct a graph demonstrating the difference in latencies relevant to code execution | ||
Inspired by | ||
https://gist.github.com/jboner/2841832 | ||
Using data from | ||
https://www.intel.com/content/www/us/en/developer/articles/technical/memory-performance-in-a-nutshell.html | ||
""" | ||
import matplotlib.pyplot as plt | ||
label = ["L1 cache", "L2 cache", "L3 cache", "RAM", "SSD", "HDD", "Ldn->Ca->Ldn"] | ||
latency_ns = [1, 4, 40, 80, 8000, 80000, 140000000] | ||
|
||
plt.figure().set_figheight(2) | ||
plt.barh(label, latency_ns) | ||
|
||
plt.xlabel("Latency (nanoseconds)") | ||
#plt.ylabel("") | ||
plt.xscale('symlog') | ||
plt.tight_layout() | ||
plt.savefig('latency.png') | ||
plt.show() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: "Optimisation Conclusion" | ||
teaching: 0 | ||
exercises: 0 | ||
--- | ||
|
||
:::::::::::::::::::::::::::::::::::::: questions | ||
|
||
- What has been learnt about writing performant Python? | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::: | ||
|
||
|
||
::::::::::::::::::::::::::::::::::::: objectives | ||
|
||
- Review what has been learnt about writing performant Python | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::: | ||
|
||
This concludes the optimisation portion of the course. | ||
|
||
An overview of how Python operates and the most important practices for achieving performant code have been introduced. | ||
|
||
Hopefully with the information from this course you will be in a better position to investigate and optimise the performance of your own code. | ||
|
||
This course's website can be used as a reference manual when profiling your own code. | ||
|
||
[Let us know](https://github.com/RSE-Sheffield/pando-python) what you think we've missed, so we can improve it too! | ||
|
||
::::::::::::::::::::::::::::::::::::: keypoints | ||
|
||
<!-- todo --> | ||
|
||
:::::::::::::::::::::::::::::::::::::::::::::::: |
Oops, something went wrong.