You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: episodes/optimisation-using-python.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ exercises: 5
23
23
24
24
This episode discusses relatively fundamental features of Python.
25
25
26
-
For students experienced with writing Python, many of these points may be unnecessary. However, self-taught students—especially if they have previously studied lower-level languages with a less powerful standard library—may have adopted “unpythonic” habits and will particularly benefit from this section.
26
+
For students experienced with writing Python, many of these points may be unnecessary. However, self-taught students—especially if they have previously studied lower-level languages with a less powerful standard library—may have adopted "unpythonic" habits and will particularly benefit from this section.
27
27
28
28
::::::::::::::::::::::::::::::::::::::::::::::::
29
29
@@ -39,7 +39,7 @@ For example, you might think to sum a list of numbers by using a for loop, as wo
Even just replacing the iteration over indices (which may be a habit you’ve picked up if you first learned to program in C) with a more pythonic iteration over the elements themselves speeds up the code by about 2×.
72
-
But even better, by switching to the builtin`sum` function our code becomes about 8× faster, doing the exact same operation!
71
+
Even just replacing the iteration over indices (which may be a habit you’ve picked up if you first learned to program in C) with a more pythonic iteration over the elements themselves speeds up the code by about 2x.
72
+
But even better, by switching to the built-in`sum()` function our code becomes about 8x faster and much easier to read while doing the exact same operation!
73
73
74
74
```output
75
75
manualSumC: 1.624ms
@@ -343,7 +343,7 @@ def builtinSplit():
343
343
This code is not just much more readable; it is also more flexible, since it does not rely on the precise formatting of the input strings.
344
344
(For example, the line `first_char = line.find("0")` in the original code assumes that the time bin starts with the digit 0. That code would likely malfunction if the input file had more than 1000 time bins.)
345
345
346
-
The code that’s executed by CPython may use a similar approach as in `manualSplit()`; however, since this is all happening “under the hood” in C code, it is once again faster.
346
+
The code that’s executed by CPython may use a similar approach as in `manualSplit()`; however, since this is all happening "under the hood" in C code, it is once again faster.
0 commit comments