~/talk

Implementing C++ Semantics in Python

Talkat NDC TechTown 2021 · 2021-08-30..09-02· [python, c-and-cpp]
slides:none on file

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

  1. 0:00Start
  2. 1:28Resource Management
  3. 2:45Real Code - Archive Reader
  4. 5:30Destructors
  5. 5:43Automatic Invocation
  6. 6:02Seamless Composition
  7. 6:23Implicit Interfaces
  8. 9:29A Proper Stack, continued
  9. 10:05Removing Hiding Boilerplate
  10. 10:27A Layer of Indirection
  11. 11:00Another Layer of Indirection
  12. 15:44Basic File Structure
  13. 16:29Making Magic
  14. 18:18Import Mechanism
  15. 19:20Import is a Function Call
  16. 19:46Where is the Magic?
  17. 23:03Main Function
  18. 24:59Base Class, implementation
  19. 25:24Decorated Methods
  20. 26:56Decorated Classes
  21. 28:44A Short Recap
  22. 30:07Looking Back, issues solution?
  23. 31:29A Case for Getters & Setters
  24. 32:52Descriptors, continued
  25. 35:26Type Annotations, continued
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.