Andrew MacIntyre wrote: > Comparative CPU & memory utilisation statistics, not to mention platform > and version of Python, would be useful hints...
During benchmarking, all versions cause all CPU to be used, but Python version has ~1.5x more CPU time allocated to it than PHP. Python is 2.4.1 > Note that the file-like object returned by makefile() has significant > portions of heavy lifting code in Python rather than C which can be a > drag on ultimate performance... If on a Unix platform, it may be worth > experimenting with os.fdopen() on the socket's fileno() to see whether > the core Python file object (implemented in C) can be used in place of > the lookalike returned from the makefile method. That's only because I need the .readline() function. In C, I'm using fgets() (with the expectation that iostream will buffer data). > Even without that, you are specifying a buffer size smaller than the > default (8k - see Lib/socket.py). 16k might be even better. The benchmark is such that all of data is < 200 bytes. I estimate that in production almost all protocol data will be < 4KB. > Although they're only micro-optimisations, I'd be interested in the > relative performance of the query method re-written as: The change (for the better) is minor (3-5%). -- http://mail.python.org/mailman/listinfo/python-list