Implementing C++ Semantics in Python
summary
A Python library replicates core C++ semantics by adding deterministic destructors (RAII), function and method decorators that push objects onto global destructor stacks, and descriptor-based members driven from type annotations so member lifetimes get auto-managed. It uses import-time module rewriting and a custom getattr to decorate functions and classes, plus an identity wrapper to safely remove members. The implementation is hacky (import recursion and global stacks), doubles for access-specifier logic, but demonstrably works for examples though not recommended for production.
AI-written summary · about
chapters (25)
- 0:00Start
- 1:28Resource Management
- 2:45Real Code - Archive Reader
- 5:30Destructors
- 5:43Automatic Invocation
- 6:02Seamless Composition
- 6:23Implicit Interfaces
- 9:29A Proper Stack, continued
- 10:05Removing Hiding Boilerplate
- 10:27A Layer of Indirection
- 11:00Another Layer of Indirection
- 15:44Basic File Structure
- 16:29Making Magic
- 18:18Import Mechanism
- 19:20Import is a Function Call
- 19:46Where is the Magic?
- 23:03Main Function
- 24:59Base Class, implementation
- 25:24Decorated Methods
- 26:56Decorated Classes
- 28:44A Short Recap
- 30:07Looking Back, issues solution?
- 31:29A Case for Getters & Setters
- 32:52Descriptors, continued
- 35:26Type Annotations, continued
related talks
27mAn Executable Semantics for Faster Development of Optimizing Python Compilers
29mC++ ♥ Python: from modules to hybrid applications
15mUsing Reflection to Generate C++ Python Bindings
02h 26mPointers in Python
36mIntroduction to C++ python extensions and embedding Python in C++ Apps
25mHow to bring your C++ project to Python land
31mUnderstanding Python from the inside: C concepts to dive into CPython fearless
01h 51m'Extending and Wrapping C and C++ with Python' - Diego Rodriguez-Losada [ ACCU 2016 ]
