Re: Web applications in python - I am curious about the overall feeling for them - Do you write web apps in python because rapid development makes up for any performance problems and if you run into problems you would rewrite it in something faster, or do you feel like a python web app can be just as good as alternatives when it comes to speed?
Put another way - when you think of python for web applications / services - do you think rapid development and speed, or just rapid development and you would go somewhere else for speed?
I like Python for the speed of development. Also, at least for these internal apps, speed is generally of secondary concern, since these aren't typically high load applications.
At reddit we solved the problem by writing the most often called parts in C and using c extensions. There is definitely more work to do there, but overall I think Python gets a bad rap as far as speed is concerned.
It's certainly not the quickest, but it isn't a dog either.
> At reddit we solved the problem by writing the most often called parts in C and using c extensions.
I'm wondering if anyone has solved these sorts of problems with Cython in the real world. It looks like a great solution for a large set of problems in terms of Python performance, since it becomes a CPython extension, but I never hear anyone talk about it. Can anyone chime in?
Cython is used all over the place in some parts of the real world, but you may not hear about those parts because they are not that connected to web app development.
The entire scientific Python ecosystem has basically moved on to Cython. Its use is quite prevalent, and it's basically displacing SWIG as the preferred wrapping tool of choice.
I get the impression that Cython is used quite a bit in the scientific computing side of Python, but not so much for web development. pandas & pyzmq are two projects I know that make serious use of Cython.
I don't think anybody equates Python with execution speed. Writing web applications in Python facilitates rapid development, and since most of the web applications are io bound, slow execution speed doesn't make noticeable difference.
> when you think of execution speed in web applications
The whole web application is not CPU bound. The parts which are CPU intensive are rewritten in performant language. For eg, if you are twitter, you still render templates in Rails, and write CPU bound services in Java/Scala. Replacing the whole app with Scala/Java will be pointless.
That doesn't mean that every time you need a service, you can't use Ruby/Python. If all your API server does is check cache for data, load data if there is a cache miss, encode json and return it, Python/Ruby will do just fine.
Understood - was just curious when it comes to CPU intensive portions what you would characterize as performant vs python. Scala/Lift is on my list to check out - So my question now is - if you got to the point of needing to write CPU bound services in Scala, why wouldn't you go ahead and write everything in Scala? Does python offer enough advantages to outweigh having to support multiple languages/environments/ecosystems?
I'm thinking pure speed is not a big differentiator these days... as long as it isn't horrible.
Why? The apps are mostly IO bound, and any large site is going to be caching, deferring slow operations, and sharding/breaking into tiers, cdns, etc, etc. The amount of time a web framework actually runs is relatively small.
Others have already mentioned what to do when performance is a problem.
Comments
Re: Web applications in python - I am curious about the overall feeling for them - Do you write web apps in python because rapid development makes up for any performance problems and if you run into problems you would rewrite it in something faster, or do you feel like a python web app can be just as good as alternatives when it comes to speed?
Put another way - when you think of python for web applications / services - do you think rapid development and speed, or just rapid development and you would go somewhere else for speed?
I like Python for the speed of development. Also, at least for these internal apps, speed is generally of secondary concern, since these aren't typically high load applications.
At reddit we solved the problem by writing the most often called parts in C and using c extensions. There is definitely more work to do there, but overall I think Python gets a bad rap as far as speed is concerned.
It's certainly not the quickest, but it isn't a dog either.
> At reddit we solved the problem by writing the most often called parts in C and using c extensions.
I'm wondering if anyone has solved these sorts of problems with Cython in the real world. It looks like a great solution for a large set of problems in terms of Python performance, since it becomes a CPython extension, but I never hear anyone talk about it. Can anyone chime in?
Cython is used all over the place in some parts of the real world, but you may not hear about those parts because they are not that connected to web app development.
The entire scientific Python ecosystem has basically moved on to Cython. Its use is quite prevalent, and it's basically displacing SWIG as the preferred wrapping tool of choice.
I get the impression that Cython is used quite a bit in the scientific computing side of Python, but not so much for web development. pandas & pyzmq are two projects I know that make serious use of Cython.
Sage [1] (which you might say is the birthplace of Cython) makes a very serious use of Cython as well.
[1] http://sagemath.org
Thanks for the information!
I don't think anybody equates Python with execution speed. Writing web applications in Python facilitates rapid development, and since most of the web applications are io bound, slow execution speed doesn't make noticeable difference.
So when you think of execution speed in web applications / services - what do you think of?
> when you think of execution speed in web applications
The whole web application is not CPU bound. The parts which are CPU intensive are rewritten in performant language. For eg, if you are twitter, you still render templates in Rails, and write CPU bound services in Java/Scala. Replacing the whole app with Scala/Java will be pointless.
That doesn't mean that every time you need a service, you can't use Ruby/Python. If all your API server does is check cache for data, load data if there is a cache miss, encode json and return it, Python/Ruby will do just fine.
Understood - was just curious when it comes to CPU intensive portions what you would characterize as performant vs python. Scala/Lift is on my list to check out - So my question now is - if you got to the point of needing to write CPU bound services in Scala, why wouldn't you go ahead and write everything in Scala? Does python offer enough advantages to outweigh having to support multiple languages/environments/ecosystems?
I'm thinking pure speed is not a big differentiator these days... as long as it isn't horrible.
Why? The apps are mostly IO bound, and any large site is going to be caching, deferring slow operations, and sharding/breaking into tiers, cdns, etc, etc. The amount of time a web framework actually runs is relatively small.
Others have already mentioned what to do when performance is a problem.