<div dir="ltr">In the other thread, I had mentioned my "extradict" implementation - it does have quite a few differences as it did not try to match namedtuple API, but it works nicely for all common use cases - these are the timeit timings:<div><div><span style="font-family:monospace"><br>(env) [gwidion@caylus ]$ python3 -m timeit --setup "from collections import namedtuple" "K = namedtuple('K', 'a b c')"
<br>1000 loops, best of 3: 362 usec per loop </span></div><div><span style="font-family:monospace"><br>(env) [gwidion@caylus ]$ python3 -m timeit --setup "from extradict import namedtuple" "K = namedtuple('K', 'a b c')" <br>10000 loops, best of 3: 20 usec per loop </span></div><div><span style="font-family:monospace"><br>(env) [gwidion@caylus ]$ python3 -m timeit --setup "from extradict import fastnamedtuple as namedtuple" "K = namedtuple('K', 'a b <br>c')"<br>
</span><span style="font-family:monospace;color:rgb(0,0,0)">10000 loops, best of 3: 21 usec per loop</span><br>
<br><br><font face="monospace">Source at:</font><br><font face="monospace"><a href="https://github.com/jsbueno/extradict/blob/master/extradict/extratuple.py">https://github.com/jsbueno/extradict/blob/master/extradict/extratuple.py</a></font><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 July 2017 at 22:34, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info" target="_blank">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Jul 17, 2017 at 05:01:58PM -0700, Ethan Furman wrote:<br>
> Guido has decreed that namedtuple shall be reimplemented with speed in mind.<br>
><br>
> I haven't timed it (I'm hoping somebody will volunteer to be the bench mark<br>
> guru), I'll offer my NamedTuple implementation from my aenum [1] library.<br>
<br>
</span>With respect Ethan, if you're going to offer up NamedTuple as a faster<br>
version of namedtuple, you should at least do a quick proof of<br>
concept to demonstrate that it actually *is* faster. Full bench marking<br>
can wait, but you should be able to do at least something like:<br>
<br>
<br>
python3 -m timeit --setup "from collections import namedtuple" \<br>
"K = namedtuple('K', 'a b c')"<br>
<br>
versus<br>
<br>
python3 -m timeit --setup "from aenum import NamedTuple" \<br>
"K = NamedTuple('K', 'a b c')"<br>
<br>
(or whatever the interface is). If there's only a trivial speed up, or<br>
if its slower, then there's no point even considing it unless you speed<br>
it up first.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
Steve<br>
</font></span><div class="HOEnZb"><div class="h5">______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
</div></div></blockquote></div><br></div>