[Python-ideas] namedtuple baseclass
Eric Snow
ericsnowcurrently at gmail.com
Sun Jan 12 17:33:57 CET 2014
On Jan 12, 2014 5:52 AM, "Yury Selivanov" <yselivanov.ml at gmail.com> wrote:
> BTW, ABC proposal aside: the current namedtuple implementation
> creates the class from a template with "exec" call. For every namedtuple,
> it's entire set of methods is created over and over again. Even for the
> memory efficiency sake, having a base class with *some* of the common
> methods (which are currently in the template) is better.
It's a trade-off. We increase the definition-time cost by using exec, but
minimize the cost of traversing the attribute lookup chain when using
instances. The purely ABC approach in the referenced issue preserves this
instance-favoring-optimization design.
-eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140112/35bd77c5/attachment-0001.html>
More information about the Python-ideas
mailing list