Python Performance

Markus Kohler markusk at bidra241.bbn.hp.com
Tue Jul 27 07:50:17 EDT 1999


"Fredrik Lundh" <fredrik at pythonware.com> writes:

> Markus Kohler <markusk at bidra241.bbn.hp.com> wrote:
> > My guess is that what calling speed makes slow on Python are all those
> > different kinds of ways to call the same function. 
> > Examples are default arguments and named arguments. 
> > IHMO these features may save some typing but they are not worth
> > sacrifying performance nor do they help increasing readability of the
> > code. 
> 
> really?  back in the 1.2 days, you had to write:
> 
>     button = Button(frame, {"text": "QUIT", "fg": "red", "command": frame.quit})
>     button.pack({"side": LEFT})
> 
> instead of:
> 
>     button = Button(frame, text="QUIT", fg="red", command=frame.quit)
>     button.pack(side=LEFT)
> 
> are you sure you find the first one being easier
> to read?

Not a big difference. But that's probaly a matter of taste. 

in Smalltalk the first call could look like:

Button  frame: aFrame text: 'QUIT' fg:'red' command: #quit

the name of the message would be frame:text:fg:command:
If you wanted  a default argument for fg for example you would
have to define a new message for example
frame:text:command:

If you get too many arguments you should change the design anyway  
 to be more OO and define a message 
frame:properties:

for example. 

> 
> on the other hand, 1.2 was much slower than the
> current releases.  go figure...
> 

I dont' doubt that. I'm just saying that there are implementation for
similiar languages how are significantly faster. 

Markus
-- 
Markus Kohler  mailto:markus_kohler at hp.com




More information about the Python-list mailing list