collections.namedtuple implemented in c.
An implementation of namedtuple written in c for warp speed.
Tested against Python3.4.2 and Python3.5 0a0.
Time to go fast.
Use qualified imports so that we can tell which namedtuple we are using.
>>> from namedtuple import namedtuple as cnamedtuple >>> from collections import namedtuple as stdnamedtuple >>> from pickle import dumps, loads
These operations scale with the number of fields.
Less cute numbers
These operations do not scale with number of fields.
std_inst is an instance of a collections.namedtuple created type with six named fields: a, b, c, d, e, and f.
In : %%timeit ...: std_inst.c 10000000 loops, best of 3: 108 ns per loop
c_inst is an instance of a cnamedtuple.namedtuple created type with six named fields: a, b, c, d, e, and f.
In : %%timeit ...: c_inst.c 10000000 loops, best of 3: 47.8 ns per loop
The project is hosted on github.
Please file all bug reports on github.
For questions or comments, feel free to email me at email@example.com
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.