Wednesday, March 30, 2005

A problem with Python

Ian Bicking wrote a passionate post where he encourages community to put more efforts into Python-for-web-application domain.

I have another complain about the Python (both for language itself and tools and libraries around it). Here it is: Python cannot fully utilize hardware resources. You see, I have several [web] programs running on my machine, some in Java and some in Python. Some of these are the apps I'm writing and debugging myself, some are third-party.

When I'm working on Java app, I have some serious stuff loaded: Eclipse IDE, Tomcat web server, database server, Firefox with API documentation opened, etc. Basically, you need 1Gb of RAM to have it all work smoothly. And even then it takes 12 seconds to redeploy an application. And we all know Java technology has sophisticated JIT compilers which means execution speed is much higher compared to Python.

What do we see in Python? Instance of Vim editor, WebKit/Apache server, may be a Firefox running, a shell. That's all. How much resources does it take? Nothing. How long does it take to redeploy a WebKit application? Nothing again. In fact, you could develop Python app on some archaic Celeron-666/256 Mb box and notice little difference with modern Athlon 2800+/1Gb. At least, that was my experience.

What the heck?

If the language can't make a serious load out of modern hardware it can't be nothing else then a toy language, right? Programming is hard and it must feel that way.

Therefore, I ask the community to put more efforts to "grow" both the language and the tools. The day I see my python application deployed in a 12 seconds to a WSGI-backed WebKit I know: we have a serious, mature language. No, not a "language" - it'd be called a "platform" by then. Definitely.


Anonymous Paul Boddie said...

Some accurate observations there. I've been using a 266MHz Pentium 2 with 128MB RAM for years and even Zope 2.7 starts up quicker on that than stuff like Tomcat on hardware 7-8 times more potent. And Zope is pretty "heavy" for a Python solution - as you say, WebKit starts up in a couple of seconds.

But then, various Java frameworks tend to exist on the basis of glorifying the stuffing of dynamic features back into the broken box, whereas smart Python frameworks will at least try and take advantage of those dynamic features already found in the language itself.

5:11 PM  
Anonymous Jon-Pierre Gentil said...

I'm pretty certain that I'm glad that Python is not some bulky "platform." Python has been criticized in the past of being slow, and the last three minor releases have been about speed improvement.

Perhaps we need to break out of our habits and embrace something that is simple and elegant, especially when it works just as well as or better than it's "super-platform" counterpart.

Twisted is a rather large network code "platform" for which things can be build. So is Zope. Both are quite large and some have even scoffed at them for being too large and bulky. Yet they start up on my Pentium II 233 almost instantly. With Java, the JVM itself takes 3-4 seconds to load. No thanks. I'll take a lightweight, elegantly implemented Python framework over Java any day.

5:58 PM  
Anonymous Ryan Tomayko said...

Great post, Max.

I've come to the conclussion that processing curly braces must be responsible for all that extra resource usage in "modern" programming environments.

6:27 PM  
Anonymous Anonymous said...

"If the language can't make a serious load out of modern hardware it can't be nothing else then a toy language, right? Programming is hard and it must feel that way."

That's a joke, right? If not, it's still a pair of very sketchy theories that I doubt are true (for my definition of 'toy language').

It's also unclear if you're claiming 12sec to "redeploy an application" is very fast or too slow.

BTW, why don't you have a database server running for the supposedly-comparable Python session?

7:04 PM  
Blogger Ian Bicking said...

Progress so far is poor, as WSGIKit is starting up in less than a second. But I'll try to work on it.

8:00 PM  
Blogger Max Ischenko said...


There is still plenty of areas to improve, besides start-up time itself. ;-)

8:38 PM  
Blogger Max Ischenko said...


Yes, this post is a half-joke. And 12 seconds difference (0 for python case) for redeploying an app is indeed astounding. To speculate, if Python VM is ten times slower(*) than Java, Tomcat must be doing about 100 times as much as WebKit does to perform roughly the same task.

I'm sure there are some valid reasons for that but still, it's a sign that something wrong here.

(*) - I mean pure execution speed of the Python code vs Java code, not underlying C implementation.

8:50 PM  
Blogger Kevin Dangoor said...

I have a three line (including comments) patch for WSGIKit that will turn Python into a Platform.

# turn Python into a Platform
import time

I decided on 24 seconds so that the Python Platform will be twice as powerful as the Java platform.

If you really want to compete with Java, though, I'd have to add another 4 lines to open up a useless XML descriptor file using ElementTree.

10:52 PM  

Post a Comment

<< Home