Skip to content

Commit 50d996f

Browse files
committed
Chapter 20
1 parent e9f53bb commit 50d996f

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

Ch20/TESTING_EXAMPLE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
For most of the examples in this chapter, please see the repository for
2+
[Textproof](https://github.com/codemouse92/textproof). Checkout the branch
3+
`example_starter` for the basic repository structure and packaging files,
4+
but without the code and tests, so you can practice along with Chapter 20.
5+
The `main` branch of that repository contains the complete source code and
6+
tests.

Ch20/profiling_with_timeit.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from timeit import timeit
2+
3+
count = 10_000_000
4+
5+
def multiple_assign():
6+
x, y, z = 'foo', 'bar', 'baz'
7+
8+
time_multiple_assign = timeit(multiple_assign)
9+
10+
def single_assign():
11+
x = 'foo'
12+
y = 'bar'
13+
z = 'baz'
14+
15+
time_single_assign = timeit(single_assign)
16+
17+
print("Multiple assignment:", time_multiple_assign, sep='\t')
18+
print("Individual assignment:", time_single_assign, sep='\t')

0 commit comments

Comments
 (0)