Skip to content

Commit

Permalink
docs: Flesh out the core dump tutorial
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
godlygeek committed Aug 1, 2024
1 parent 1490caf commit 3e23f5e
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 180 deletions.
28 changes: 0 additions & 28 deletions docs/assert.py

This file was deleted.

152 changes: 0 additions & 152 deletions docs/core_tutorial.rst

This file was deleted.

1 change: 1 addition & 0 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Contents

tutorials/deadlock
tutorials/random_prime_number
tutorials/core_tutorial

.. toctree::
:caption: Project Information
Expand Down
20 changes: 20 additions & 0 deletions docs/tutorials/core_tutorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import gc


def types_found_in_tuples():
elem_types = set()

for obj in gc.get_objects():
if isinstance(obj, tuple):
elem_types.update(map(type, obj))

for elem_type in elem_types:
yield elem_type


print("Printing with multiple calls to print():")
for t in types_found_in_tuples():
print(t)

print("Printing with one call to print():")
print(*types_found_in_tuples(), sep="\n")
Loading

0 comments on commit 3e23f5e

Please sign in to comment.