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:

(env) [gwidion@caylus ]$ python3 -m timeit --setup "from collections import
namedtuple"     "K = namedtuple('K', 'a b c')"
1000 loops, best of 3: 362 usec per loop

(env) [gwidion@caylus ]$ python3 -m timeit --setup "from extradict import
namedtuple"     "K = namedtuple('K', 'a b c')"
10000 loops, best of 3: 20 usec per loop

(env) [gwidion@caylus ]$ python3 -m timeit --setup "from extradict import
fastnamedtuple as namedtuple"     "K = namedtuple('K', 'a b
c')"
10000 loops, best of 3: 21 usec per loop


Source at:
https://github.com/jsbueno/extradict/blob/master/extradict/extratuple.py

On 17 July 2017 at 22:34, Steven D'Aprano <st...@pearwood.info> wrote:

> On Mon, Jul 17, 2017 at 05:01:58PM -0700, Ethan Furman wrote:
> > Guido has decreed that namedtuple shall be reimplemented with speed in
> mind.
> >
> > I haven't timed it (I'm hoping somebody will volunteer to be the bench
> mark
> > guru), I'll offer my NamedTuple implementation from my aenum [1] library.
>
> With respect Ethan, if you're going to offer up NamedTuple as a faster
> version of namedtuple, you should at least do a quick proof of
> concept to demonstrate that it actually *is* faster. Full bench marking
> can wait, but you should be able to do at least something like:
>
>
> python3 -m timeit --setup "from collections import namedtuple" \
>     "K = namedtuple('K', 'a b c')"
>
> versus
>
> python3 -m timeit --setup "from aenum import NamedTuple" \
>     "K = NamedTuple('K', 'a b c')"
>
> (or whatever the interface is). If there's only a trivial speed up, or
> if its slower, then there's no point even considing it unless you speed
> it up first.
>
>
> --
> Steve
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to