all() is slow?

Chris Angelico rosuav at gmail.com
Wed Nov 9 18:15:07 EST 2011


On Thu, Nov 10, 2011 at 10:01 AM, Devin Jeanpierre
<jeanpierreda at gmail.com> wrote:
>> If it were someone other than Raymond Hettinger responsible for the use
>> of exec in namedtuple, I'd be a lot more suspicious of it.
>
> I'm not going to be less suspicious based on a name. It reads like
> insanity, and the justification was terrible.

It's said that code exists foremost for humans to read, and only
incidentally for computers to execute. I believe that this is inverted
for library code; as long as the _interface_ is clean, you can get
away with some messy internals, because it's going to be executed far
more often than actually read. Python programmers can use namedtuples
happily without knowing that the implementation uses exec.

The justification is, if I understand correctly, that the alternative
is worse. That's plenty of justification imho.

ChrisA



More information about the Python-list mailing list