Skip to content

Commit 00c0945

Browse files
committed
docs: Flesh out the core dump tutorial
The example I originally suggested for the core dump tutorial is a bit too trivial to make an interesting example. Instead, Pablo helped me come up with an example of a known way to crash the interpreter where the root cause is not so obvious, which makes a far more engaging example for readers to dig into and try to make sense of. Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
1 parent a273cea commit 00c0945

File tree

5 files changed

+308
-180
lines changed

5 files changed

+308
-180
lines changed

docs/assert.py

Lines changed: 0 additions & 28 deletions
This file was deleted.

docs/core_tutorial.rst

Lines changed: 0 additions & 152 deletions
This file was deleted.

docs/overview.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Contents
5454

5555
tutorials/deadlock
5656
tutorials/random_prime_number
57+
tutorials/core_tutorial
5758

5859
.. toctree::
5960
:caption: Project Information

docs/tutorials/core_tutorial.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import gc
2+
3+
4+
def types_found_in_tuples():
5+
elem_types = set()
6+
7+
for obj in gc.get_objects():
8+
if isinstance(obj, tuple):
9+
elem_types.update(map(type, obj))
10+
11+
for elem_type in elem_types:
12+
yield elem_type
13+
14+
15+
print("Printing with multiple calls to print():")
16+
for t in types_found_in_tuples():
17+
print(t)
18+
19+
print("Printing with one call to print():")
20+
print(*types_found_in_tuples(), sep="\n")

0 commit comments

Comments
 (0)