On 20 June 2017 at 12:05, INADA Naoki firstname.lastname@example.org wrote:
Namedtuple in Python make startup time slow. So I'm very conservative to convert tuple to namedtuple in Python.
Aye, I don't think a Python level wrapper would be the right way to go here - while namedtuple is designed to be as cheap as normal tuples in use, the same can't be said for the impact on startup time.
As context for anyone not familiar with the time module precedent that
Guido mentioned, we have a C level
PyStructSequence that provides
some of the most essential namedtuple features, but not all of them:
So there's potentially a case to be made for:
The main argument against doing so is that the initialisation API for it is pretty weird by the standards of the rest of the Python C API - it's mainly designed for use as a C level type factory, rather than intended to be used directly. That's also why there isn't a Python level API for it - it's designed around accepting C level structs as inputs, which doesn't translate well to pure Python code (whereas the collections.namedtuple API works well in pure Python code, but doesn't translate well to C code).
-- Nick Coghlan | email@example.com | Brisbane, Australia