Skip to content

Commit 5725fea

Browse files
JostMigendaRobadob
authored andcommitted
resetting some typographic changes
Should change these consistently across the whole course, see #64
1 parent 9377abf commit 5725fea

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

episodes/optimisation-using-python.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exercises: 5
2323

2424
This episode discusses relatively fundamental features of Python.
2525

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.
2727

2828
::::::::::::::::::::::::::::::::::::::::::::::::
2929

@@ -39,7 +39,7 @@ For example, you might think to sum a list of numbers by using a for loop, as wo
3939
import random
4040
from timeit import timeit
4141

42-
N = 100_000 # Number of elements in the list
42+
N = 100000 # Number of elements in the list
4343

4444
# Ensure every list is the same
4545
random.seed(12)
@@ -68,8 +68,8 @@ print(f"manualSumPy: {timeit(manualSumPy, globals=globals(), number=repeats):.3f
6868
print(f"builtinSum: {timeit(builtinSum, globals=globals(), number=repeats):.3f}ms")
6969
```
7070

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 .
72-
But even better, by switching to the builtin `sum` function our code becomes about 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!
7373

7474
```output
7575
manualSumC: 1.624ms
@@ -343,7 +343,7 @@ def builtinSplit():
343343
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.
344344
(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.)
345345

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.
347347

348348
```python
349349

0 commit comments

Comments
 (0)