On Mon, Nov 16, 2026 at 12:53:03PM -0800, Douglas Anderson wrote: > Iterating over a node's properties via `FdtRo.properties()` currently > crosses the Python/SWIG boundary `1 + 2 * num_props` times per node > (`first_property_offset()`, `get_property_by_offset()`, and > `next_property_offset()`, along with their Python `check_err()` and > `check_err_null()` wrappers). When walking every property across large > device trees from Python, those per-property SWIG round-trips dominate > runtime. > > Add a C helper `fdt_node_properties_stub()` in `pylibfdt/libfdt.i` > backing `FdtRo.properties()` so all `Property` objects for a node are > collected in a single C call per node, interning property name strings > via `PyUnicode_InternFromString()`. Also add an invalid-offset exception > check to `testPropertiesIterator` in `tests/pylibfdt_tests.py`. > > On one stress test (walking all ~573k nodes and ~2.06M properties across > 438 arm64 Qualcomm DTBs) this reduced `FdtRo.properties()` time by > ~1.8x. > > Assisted-by: Gemini:gemini-pro-prerelease > Signed-off-by: Douglas Anderson Hm, optimizing pylibfdt has never been a focus, on the general assumption that if speed is really important to you, you shouldn't be using Python. I'm happy enough with patch 4, because it's a speed win with a very small and simple change. This optimization is a much larger chunk of code, so I'm not so convinced this is worth the source complexity we pay for it. That's not an outright rejection, but I'd need convincing this is worth it. -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson