On Mon, Jul 17, 2017 at 8:16 PM, Barry Warsaw <barry at python.org> wrote: > .. > > class Foo(NamedTuple, fields = 'x,y,z'): > > ... > > > > Then the name is explicit and you get to add methods > > etc. if you want. > > Yes, I like how that reads. > > I would prefer class Foo(metaclass=namedtuple, fields = 'x,y,z'): ... which while slightly more verbose, does not lie about what namedtuple is - a factory of classes. This, however is completely orthogonal to the issue of performance. As I mentioned in my previous post, namedtuple metaclass above can be a simple function: def namedtuple(name, bases, attrs, fields=()): # Override __init_subclass__ for Python 3.6 return collections.namedtuple(name, fields) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20170717/6e5ee91f/attachment-0001.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4