[issue30020] Make attrgetter use namedtuple

2017-04-08 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with the others. This is unnecessary feature creep that doesn't make sense for typical use cases. -- nosy: +rhettinger resolution: -> rejected stage: -> resolved status: open -> closed ___ Python track

[issue30020] Make attrgetter use namedtuple

2017-04-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I vote -1 too. 1. As was said, this doesn't work with all attribute names. 2. This adds circular dependency between operator and collections modules. 3. This increases memory consumption and startup time for small programs that don't use the collections modul

[issue30020] Make attrgetter use namedtuple

2017-04-08 Thread Christian Heimes
Christian Heimes added the comment: I'm with RDM and vote -1, too. A namedtuple is a bit more costly than a normal tuple. That's especially try for dynamic attrgetter() that are defined ad-hoc, e.g. as key function for sorted(). The creation of type classes doesn't come for free. -- n

[issue30020] Make attrgetter use namedtuple

2017-04-08 Thread R. David Murray
R. David Murray added the comment: This is a clever idea, but I vote -1 for this proposal. I think it makes attrgetter more complex for little purpose. The fact that only some attribute names work and the others get mangled makes the API very ugly and not, IMO, desirable. Finally, if you wa

[issue30020] Make attrgetter use namedtuple

2017-04-08 Thread Isaac Morland
Isaac Morland added the comment: What are the "other issues"? As to the issue you raise here, that's why I use rename=True. First create a type with an underscore attribute: >>> t = namedtuple ('t', ['a', '1234'], rename=True) (just an easy way of creating such a type; used of namedtuple spec

[issue30020] Make attrgetter use namedtuple

2017-04-08 Thread Josh Rosenberg
Josh Rosenberg added the comment: Aside from other issues, namedtuples can't have fields beginning with underscores, attrgetter can get attributes beginning with underscores (and dotted attributes for that matter). There isn't going to be an obvious or intuitive mapping to apply here. ---

[issue30020] Make attrgetter use namedtuple

2017-04-08 Thread Isaac Morland
Isaac Morland added the comment: I've attached a file which illustrates what I'm proposing to happen with the examples from the help. Note that attrgetter (attr) is not affected, only attrgetter (*attrs) for more than one attribute. The idea is that tuples resulting from attrgetter functions

[issue30020] Make attrgetter use namedtuple

2017-04-07 Thread Steven D'Aprano
Steven D'Aprano added the comment: Before writing a patch that may be rejected, can you explain in detail what change you propose? Example(s) will be good. For example: py> from operator import attrgetter py> f = attrgetter('keys') py> f({}) I don't see a tuple here, so what (if anything) ar

[issue30020] Make attrgetter use namedtuple

2017-04-07 Thread Isaac Morland
New submission from Isaac Morland: I would find it useful if the tuples returned by attrgetter functions were namedtuples. An initial look at the code for attrgetter suggests that this would be an easy change and should make little difference to performance. Giving a namedtuple where previou