Skip to main content

22 docs tagged with "python-internals"

View all tags

Bytecode Inspection - Inside the code Object

Understand Python bytecode and the code object at engineering depth - all co_ attributes explained, how .pyc files work, reading bytecode with marshal, the line number table, closures in bytecode, and practical uses in debuggers and test frameworks.

Disassembly with dis - Reading CPython Bytecode

Master Python bytecode disassembly with the dis module at engineering depth - reading disassembly output, key opcodes explained, value stack evolution, comparing equivalent Python patterns at the instruction level, and practical performance insights.

Memory Profiling - tracemalloc, memory_profiler, objgraph, and pympler

Profile and debug Python memory usage at engineering depth - sys.getsizeof shallow vs deep size, tracemalloc snapshots and leak detection, memory_profiler line-by-line analysis, objgraph retention paths, pympler recursive sizing, and practical workflows for diagnosing real-world memory leaks.

Module 03 - Python Internals Overview

Understand CPython's implementation details at engineering depth - bytecode, the eval loop, the GIL, reference counting, garbage collection, memory profiling, sys/inspect, and the import system.

Project 01 - Bytecode Visualizer

Build a Python bytecode analysis tool using the ast module, dis.get_instructions(), and CPython's value stack model. Parse source to AST, disassemble to bytecode, simulate stack evolution, and compare two implementations side by side.

Project 02 - Mini Profiler Tool

Build a production-quality Python profiler using sys.setprofile(), tracemalloc, and call tree construction. Supports context manager and decorator usage, formatted report tables, run comparison, and JSON export for CI integration.

sys and inspect - Runtime Introspection at Engineering Depth

Master the sys and inspect modules at engineering depth - sys.argv, sys.path, sys.modules cache, sys.settrace, sys._getframe, inspect.signature with all parameter kinds, inspect.getsource, inspect.stack, and how FastAPI, pytest, and click use these modules to build their core features.