2

i'm stress testing 2 different projects: one is proxsmtpd - smtp proxy written in C And the other one, smtp_proxy.py, which i developed under 1 hour, with use of asyncore and smtpd python modules.

I stressed both projects under heavy load, and found out that proxsmtpd is able to hold 400 smtp sessions / sec, while my python program, is able to do only 160 smtp sessions /sec.

So, my question is, does it because there are some performance limitations in asyncore, or C programs are just faster? Or maybe it's me, using asyncore in inefficient way?

Vladimir
  • 427
  • 1
  • 4
  • 9
  • If you're fairly new to Python then it's a pretty safe bet that you're doing things in an inefficient manner. Newcomers to Python will often write things "C-style", iterating over individual characters in strings, not making effective use of Python primitives, generally working at too low a level. Unless you're sure your approach is "Pythonic" and efficient, Noufal's suggestion to profile is good: do that and if you don't know why the slowest code is so slow, post an update with code. – Peter Hansen Jan 07 '10 at 17:45

1 Answers1

2

I think it's a fair assumption that given a good C version and a good Python version, the C version will be faster and more scalable but in your case, you might want to run a profiler and see why and where your program is not scaling up as much as the C version. Perhaps you can uncover the tight spots and optimise it to squeeze some more performance out of your code. Also, I don't know much about asyncore but the first Python library people seem to gravitate towards when they want to do async stuff is twisted. So, perhaps there is a performance improvement there.

Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169