Abstract tricks: how abstract base classes can help you to solve difficult challenges.
summary
Shows a concrete library: a regex translator that expands XML Schema shorthands into Python regexes and compiles them, an implementation of XML Schema atomic types using ABCMeta to override instance checks, and a memory‑efficient character set implemented as a mutable subset set keyed on ~6,000 Unicode intervals to avoid loading all ~150,000 assigned code points. The regx subpackage is ~2,000 lines, passes ~50,000 tests, and uses ABCMeta instance check and proxy types to reuse built‑in types while enforcing schema validation.
AI-written summary · about
chapters (8)
- 0:00Introduction to talk
- 1:55Abstract base classes overview
- 7:06Benefits of ABCs in code
- 10:43XML regex processing challenge
- 17:39Unicode subsets with ABCs
- 21:03Atomic types and expat data
- 25:00Proxy classes for type checks
- 27:14Conclusion and summary
related talks
34mAn Intuitive Grasp of RegEx’s in Python
57mThe Art of Subclassing
24m"A Confession of My Python Sins"
23mReducing your memory footprint by 75% with 6 lines of code
34mFinding and creating gambiarras with python ASTs
31mDon't Do This
50mPerformance tricks learned from low level developers
30mDoing stupid things with ASTs
