What is different with Python ?

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sun Jun 12 13:41:37 EDT 2005


On Sun, 12 Jun 2005 08:11:47 -0400, Roy Smith wrote:

> The point I was trying to make was that as computer science progresses, 
> stuff that was really important to know a lot about becomes more and more 
> taken for granted.  This is how we make progress.
> 
> I used to worry about memory busses at the milivolt and microsecond level.  
> I knew about termination impedances and wired-OR logic, and power budgets 
> and all that good stuff.  Today all I know about memory is you go to 
> www.crucial.com, type in your Visa card number, and the nice UPS guy shows 
> up with some SIMMs in a few days.

Yes. But (to a first approximation) memory either works or it doesn't. And
we never need to worry about it scaling, because you don't get to assemble
your own SIMMs -- you buy them pre-made. Software is nothing like that.

[snip]
> Just like you can't even begin to think about building today's
> GUI-driven desktop applications if you're still worrying about
> individual logic gates, you can't begin to think about solving some of
> these really hard problems (and others we haven't even imagined) if
> you're still worrying about memory buffer reference counting and garbage
> collection. Yesterday's research projects are today's utilities and
> tomorrow's historical footnotes.

Nice in theory, but frequently breaks down in practice. Let's take a nice,
real, Python example:

I write an text-handling application in Python. I've taken your advice,
and don't worry about messy details about the language implementation,
and concentrated on the application logic. Consequently, I've used the
idiom:

new_text = ""
for word in text:
    new_text = new_text + process(word)

I test it against text containing a few thousand words, and performance is
good. Then my customers use my application in the real world, using texts
of a few hundreds of millions of words, and performance slows to a painful
crawl.

Python does a good job of insulating the developer from the implementation
details, but even in Python those details can sometimes turn around and
bite you on the behind. And your users will discover those bum-biting
situations long before your testing will.

Joel of "Joel On Software" discusses this issue here:

http://www.joelonsoftware.com/articles/fog0000000319.html

Of course, we should not prematurely optimise. But we should also be aware
of the characteristics of the libraries we call, so we can choose the
right library. 

Fortunately, a high-level language like Python makes it comparatively easy
to refactor a bunch of slow string concatenations into the list-append
plus string-join idiom.


-- 
Steven.






More information about the Python-list mailing list