[Python-ideas] Add recordlcass to collections module

Thautwarm Zhao yaoxiansamma at gmail.com
Sat Sep 1 14:22:11 EDT 2018


>
>
> ---------- Forwarded message ----------
> From: Martin Bammer <mrbm74 at gmail.com>
> To: python-ideas at python.org
> Cc:
> Bcc:
> Date: Sat, 1 Sep 2018 09:47:04 +0200
> Subject: [Python-ideas] Add recordlcass to collections module
> Hi,
>
> what about adding recordclass
> (https://bitbucket.org/intellimath/recordclass) to the collections module
>
> It is like namedtuple, but elements are writable and it is written in C
> and thus much faster.
>
> And for convenience it could be named as namedlist.
>
> Regards,
>
> Martin
>
>
There are a problem which prevent you to reach your goals.

As list in Python is already that efficient, a wrapper of this list in C to
supply so-called namedlist interface could not be that efficient.

Member accessing in Python bytecode requires looking up corresponding
attribute in a hashtable, if you want to access a list by attribute,
actually there is an overhead. This is nothing to do with C implementation.
See https://docs.python.org/3/library/dis.html#opcode-LOAD_ATTR
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180902/de38b615/attachment.html>


More information about the Python-ideas mailing list