++namedtuple: Python style Named Tuples in C++20
summary
Implements Python-style named tuples in C++20 with a concrete snippet (namedtuple{"price"_t = 42, "size"_t = 1'000u}) using "price"_t UDL and a small std::fixed_string helper to make each name a unique compile-time type. Uses Concepts, new lambda tricks and operator[] to do operator[] compile-time lookup, provides std::tuple_size/get shims so structured bindings work, and shows a ~100-line C++20 reference implementation that prints and converts to JSON. Benchmarks find compilation time comparable or sometimes faster than std::tuple; packing optimization is demonstrated as doable.
AI-written summary · about
chapters (12)
- 0:00Start
- 1:35The Motivation so Name Tuples Are Coming from Python
- 2:28Main Issues with the Sdx
- 4:53Benefit of Potential Tuple Implementations of the Structs
- 5:03Draw Polymorphism
- 14:05Metastract
- 25:36Implementation
- 39:12Nested Composite Tuples
- 45:10Immediately Invoked Function Expression
- 45:52Printing the Tuple
- 48:07Showcase
- 51:28The Benchmark of Compilation Times
related talks
25m"Boosting Python Numeric Computations with Dynamic C++ Integration"
43mHigher order functions for ordinary C++ developers
01h 21mAccelerating Python With C++
22mEasier Classes: Python Classes Without All The Cruft
39mDyND: Enabling complex analytics across the language barrier
29mC++ ♥ Python: from modules to hybrid applications
01h 02mWriting Python Bindings for C++ Libraries: Easy-to-use Performance
48mIntegrate Python and C++ with pybind11
