generator expressions: performance anomaly?

Antoon Pardon apardon at forel.vub.ac.be
Wed Jan 19 04:21:45 EST 2005


Op 2005-01-18, Steve Holden schreef <steve at holdenweb.com>:
> Antoon Pardon wrote:
>
>> Op 2005-01-18, Steve Holden schreef <steve at holdenweb.com>:
>> 
>> 
>>>Python is *designed* as a dynamic language. I wish you would embrace 
>>>this aspect rather than continually trying to shoehorn it into a static 
>>>straitjacket. Efficiency is good. Flexibility is better.
>> 
>> 
>> Flexibility is better? IMO flexibilty implies more than one way to do
>> things. But that is a big no no here in c.l.py.
>> 
> Become one with the language.

That is difficult if I hear so many contradictionary things about
it. Sometimes I have the feeling that the Zen of python is more
for poet like people, not for the extreme analytical kind, like
me.

>> I also see a lot of remarks that go: "Don't do this!" when some of
>> the more dynamic aspects are talked about, because there are 
>> security risks involved. One of the results was that I ended up
>> writing a parser for some kind of game instead of just dumping the
>> structure in textual form and doing an eval of the file when reading
>> it in. But if I need a parser I could just as well used a static
>> language.
>> 
> Wow, you mean you actually *took* some advice? :-) Perhaps this whole 
> thing has arisen because you feel you were badly advised. It looks as 
> though your programming skill level might have been underestimated. Your 
> ability to wring an argument to a merciless death could never be.

Again the problem is the many contradictionary arguments I get from
this group. My impression is that any time I do a suggestion here
or make a remark sooner or later someone will quote one of the rules
of python and will consider the matter closed by that. But those
rules can be used to support or reject any proposition.

If someone proposes to introduce an exception, the rule quoted
is: No exception is so importan to break the rule.

If someone proposes to make python more consistent, the rule
quoted is: practicallity beats purity.

So in the end I get the feelings that the strengths of arguments
doesn't matter here. If someone doesn't like a proposition, he
just looks for the rule it will break (and since the rules contradict
each other he will find one) and produce it as the final argument
for why the proposal won't work.

>> I'm beginning to guess the dynamic aspect of python is overrated.
>> 
> You shouldn't have to guess, and it isn't.
>
> Certain of its dynamic aspects do demand a certain care rather than 
> casual usage, however, which leads to rules of thumb like "don't use 
> mutables as dictionary keys". Yes, of course you can, but to a newbie 
> your behavior (it seems to me) is a bit like this:

But I am not talking to newbees. I am talking about documentation that
is in the language reference and things that I'm told.

If it would just be the tutorial and like wise documents that stated
to not use mutables as dictionary keys I could live with that. But
if the language reference suggest the same you can no longer claim
it is for the newbee's sake.

> Me (to newbie): "... And, of course, you want to be careful not to shoot 
> yourself in the foot."

> You: ":Well, actually, if you use a .22 and aim very carefully between 
> the big toe and its neighbor there's a 96% chance that you will only 
> suffer serious burns".
>
> So, please understand, I'm not trying to say that (most of) your 
> utterances are untrue, or question your knowledge of the Python 
> environment. I'm just trying to bring the day closer when you will be 
> able to watch me write something that's only 99% true and happily walk 
> away without writing a thousand-word essay on the remaining 1% case.

Well the problem may be I don't consider the person you are talking
to as a newbee. Just the fact that he asks a question that marks
him as a newbee in python doesn't mean he is a newbee programmer.

But you do have a point that I have a tendency to put salt on
any snail. I'll try to restrain myself a bit more in the future.

-- 
Antoon Pardon



More information about the Python-list mailing list