views:

268

answers:

4

I want to start writing a http proxy that will modify responses according to some rules/filters I will configure. However, before I start coding it, I want to make sure I'm making the right choice in going with Python. Later, this tool would have to be able to process a lot of requests, so, I would like to know I can count on it later on to be able to perform when "push comes to shove".

+4  A: 

As long as the bulk of the processing uses Python's built-in modules it should be fine as far as performance. The biggest strength of Python is its clear syntax and ease of testing/maintainability. If you find that one section of your code is slowing down the process, you can rewrite that section and use it as a C module, while keeping the bulk of your control code in Python.

However if you're looking to make the most optimized Python Code you may want to check out this SO post.

Jweede
+2  A: 

This will depend on the library you use more than the language itself. The twisted framework is known to scale well.

Here's a proxy server example in python/twisted to get you started.

Bottomline: choose your third party tools wisely and I'm sure you'll be fine.

Triptych
good suggestion!
Jweede
I don't think I will be using any third party libraries. Not in the initial phase, anyway.
Geo
I'd advise against that approach, but to each his own. Still, the fact that twisted exists and is quite scalable should answer your question.
Triptych
+2  A: 

Yes, I think you will find Python to be perfectly adequate for your needs. There's a huge number of web frameworks, WSGI libraries, etc. to choose from, or learn from when building your own.

There's an interesting post on the Python History blog about how Python was supporting high performance websites in 1996.

zweiterlinde
+2  A: 

Python performs pretty well for most tasks, but you'll need to change the way you program if you're used to other languages. See Python is not Java for more info.

If plain old CPython doesn't give the performance you need, you have other options as well.
As has been mentioned, you can extend it in C (using a tool like swig or Pyrex). I also hear good things about PyPy as well, but bear in mind that it uses a restricted subset of Python. Lastly, a lot of people use psyco to speed up performance.

Jason Baker