[Python-Dev] namedtuple implementation grumble
Eric V. Smith
eric at trueblade.com
Tue Jun 10 20:33:27 CEST 2014
More information about the Python-Dev mailing list
Tue Jun 10 20:33:27 CEST 2014
- Previous message: [Python-Dev] namedtuple implementation grumble
- Next message: [Python-Dev] [Python-ideas] Expose `itertools.count.start` and implement `itertools.count.__eq__` based on it, like `range`.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>> I wonder how a hybrid approach would work? Use a dynamically-created >> class, but then construct the __new__ method using exec and inject it >> into the new class. As far as I can see, it's only __new__ that benefits >> from the exec approach. >> >> Anyone tried this yet? Is it worth an experiment? > > I'm not sure what the benefit would be. Other than the ast manipulations > for __new__, the rest of the non-exec code is easy to understand. I misread this, sorry. This might work for collections.namedtuple, but is probably not worth the hassle or churn of changing it. The main reason I switched to ast for namedlist is because generating the text version of __new__ or __init__ with default parameter values was extremely difficult, so an approach of exec-ing that one function wouldn't work for me. Eric.
- Previous message: [Python-Dev] namedtuple implementation grumble
- Next message: [Python-Dev] [Python-ideas] Expose `itertools.count.start` and implement `itertools.count.__eq__` based on it, like `range`.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list