Skip to content

Instantly share code, notes, and snippets.

View switowski's full-sized avatar
🐍
I'm Pythoning

Sebastian Witowski switowski

🐍
I'm Pythoning
View GitHub Profile
Function 3.9.14 3.10.7 3.11.0
Filter [msec] 26.7 (28.4) 26 (27.1) 19.6 (20.4)
Pi [sec] 18.4 (19.2) 17.3 (17.5) 14.1 (14.3)
Bubble [sec] 8.26 (8.46) 7.96 (8.06) 4.72 (4.75)
Function 3.7.14 3.8.14 3.9.14 3.10.7 3.11.0 3.7/3.11
test_permission2() [nsec] 218 145 148 145 140 1.68
test_forgiveness2() [nsec] 91.9 70.4 72 83.1 71.7 1.31
test_permission3() [nsec] 77.4 60.9 61.9 57.1 40.5 1.88
test_forgiveness3() [µsec] 256 251 239 283 307 0.83
count_numbers() [µsec] 46.8 47.5 47.4 46.6 41 1.14
generator() [µsec] 47.1 47.7 47.6 45.3 39.5 1.18
for_loop() [msec] 27.2 26.5 26.8 25.6 19.4 1.39
list_comprehension() [msec] 18.3 18 18.6 17.7 17.3 1.04
test_sort() [msec] 175 175 176 176 175 0.97
In [7]: %xmode
Exception reporting mode: Verbose
In [8]: solve()
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-10-6f300b4f5987> in <module>
----> 1 solve()
global solve = <function solve at 0x109312b80>
In [5]: %xmode
Exception reporting mode: Context
In [6]: solve()
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-8-6f300b4f5987> in <module>
----> 1 solve()
~/workspace/iac/solver.py in solve()
In [3]: %xmode
Exception reporting mode: Plain
In [4]: solve()
Traceback (most recent call last):
File "<ipython-input-6-6f300b4f5987>", line 1, in <module>
solve()
File "/Users/switowski/workspace/iac/solver.py", line 27, in solve
sol_part1 = part1(vals)
File "/Users/switowski/workspace/iac/solver.py", line 16, in part1
In [1]: %xmode
Exception reporting mode: Minimal
In [2]: solve()
IndexError: list index out of range
$ python -m timeit -s "from permission_vs_forgiveness import test_lbyl3" "test_lbyl3()"
2000000 loops, best of 5: 135 nsec per loop
$ python -m timeit -s "from permission_vs_forgiveness import test_aff3" "test_aff3()"
500000 loops, best of 5: 562 nsec per loop
# permission_vs_forgiveness.py
class BaseClass:
pass # "hello" attribute is now removed
class Foo(BaseClass):
pass
FOO = Foo()
$ python -m timeit -s "from permission_vs_forgiveness import test_lbyl2" "test_lbyl2()"
500000 loops, best of 5: 326 nsec per loop
$ python -m timeit -s "from permission_vs_forgiveness import test_aff2" "test_aff2()"
2000000 loops, best of 5: 176 nsec per loop
# permission_vs_forgiveness.py
class BaseClass:
hello = "world"
bar = "world"
baz = "world"
class Foo(BaseClass):
pass