I've just completed and uploaded the types module workbook to my standardlib-datastruct repository. This addition dives into Python's runtime object types and CPython internals.
What's Inside
The types workbook contains 18 exercises covering runtime object types from Python's types module. The goal is coverage, not order—master the types that power Python under the hood.
Types Covered
Function and Method Types:
-
FunctionTypeandLambdaType- Regular functions and lambdas -
MethodType- Bound methods -
BuiltinFunctionTypeandBuiltinMethodType- Built-in callables
Async and Generator Types:
-
GeneratorType- Regular generators -
AsyncGeneratorType- Async generators -
CoroutineType- Coroutine objects
Code and Execution Types:
-
CodeType- Compiled bytecode objects -
FrameType- Execution frames -
TracebackType- Exception tracebacks
Descriptor Types:
-
MemberDescriptorType- Class attribute descriptors -
WrapperDescriptorType- Low-level built-in descriptors -
GetSetDescriptorType- C-implemented properties
Utility Types:
-
MappingProxyType- Read-only dictionary views -
ModuleType- Module objects -
EllipsisType- The...singleton -
NotImplementedType- TheNotImplementedsingleton
Each exercise includes a clear problem statement and a complete solution with working code examples.
About This Learning Path
This workbook is not beginner-friendly by design. It assumes you understand:
- Python's object model and how types work
I've included only the functionalities I find necessary and practical. This isn't an exhaustive reference—it's a focused learning tool for understanding Python's runtime type system.
Learning Note: CPython Descriptors
While working on this workbook, I discovered you can understand CPython's internal descriptor types without diving into C code:
-
MemberDescriptorType- Attributes implemented in CPython (like accessing attributes) -
GetSetDescriptorType- Properties implemented in CPython (likepropertybut in C) -
WrapperDescriptorType- Methods implemented in CPython
This approach lets you understand Python's internals through the types module rather than reading C source code.
Note: Some types in this workbook aren't normally used in everyday code—I included them out of curiosity. Feel free to skip those if you want and focus on what's practical for your needs.
Python 3.11+ Features
I'm using Python 3.11 for my learning. The types module provides access to runtime types that are fundamental to understanding how Python works internally.
My Approach
I'm learning the standard library by:
- Selecting the most useful modules and functions
- Creating hands-on exercises that demonstrate real use cases
- Building a personal reference that I can return to
- Sharing it for others who want to follow a similar path
This repository (standardlib-datastruct) focuses on standard library tools that are useful when handling data structures. This may not include everything—I only add what I find necessary and want to learn. It's my curated selection based on practical needs.
Some standard library modules may be skipped because 3rd party or external libraries handle those use cases better. I focus on what's worth learning from the standard library itself.
This is my way of learning—practical, focused, and exercise-driven. If you're past the beginner stage and want to level up your Python skills, this might resonate with you.
Get the Workbook
The types workbook is available now in the repository as types.7z. It includes:
-
types_exercises_workbook.md- Markdown format -
types_exercises_workbook.pdf- PDF format (generated with pandoc + MiKTeX) -
types_workbook.py- Source generator script
Feel free to download, work through the exercises, and adapt them to your learning style.
Repository: github.com/hejhdiss/standardlib-datastruct
Previous additions: functools workbook, itertools workbook
Note: This is a living project. I'll continue adding more standard library modules as I complete them. Follow along if this learning approach works for you!
Top comments (0)