|
Prev: Brand Watches Rado Men's DiaStar watch #R12391633 Discount, Replica, Fake
Next: Brand Watches Seiko Ladies Watches Criteria SND873P - AA Discount, Replica, Fake
From: Bartc on 18 Apr 2008 18:34 <thomas.mertes(a)gmx.at> wrote in message news:5b19cc53-9ae8-47d3-9137-35626c87b555(a)a1g2000hsb.googlegroups.com... > On 18 Apr., 14:18, "Bartc" <b...(a)freeuk.com> wrote: >> "Anonymous" <no-respo...(a)no-server.com> wrote in message >> > I just tested a standard XML processing library (from Python, no less) >> > and it managed to parse over 2.55 million lines per second. If I wrote >> > the program and callbacks in pure C, I would expect it to be faster. >> >> I can't imagine Python doing anything much 2.5 million times a second. >> Just >> an empty for-loop with 2.5m iterations takes about a second on my >> machine. > > Is Python really that slow? > An empty loop with 2.5m iterations inclusive reading the program > (3666 lines total) needs approx. 0.141 seconds (measured with time) > when the Seed7 program is interpreted. > Said that: Empty loops are not an optimal benchmark. I don't think Python can have a proper empty loop; the following code: for i in xrange(2500000): pass executed in some 700ms on a slow 1GHz pentium laptop. However this was version 2.2.3 from 2003. When I tried 2.5.2, this was reduced to under 400ms. My own toy bytecode language did it in 30ms (but has optimised for-loops). C took 17ms, down to 6ms when optimised. The point was that parsing 2.5m lines of XML in one second seems unlikely in pure Python code, given that it has enough trouble doing nothing in the same time, even if Anonymous' machine is somewhat faster. It must have a lot of help, in which case Python is just used as a scripting language, which strangely enough, is exactly what it is. -- Bart
From: Anonymous on 20 Apr 2008 15:37
On Fri, 18 Apr 2008 12:18:49 +0000, Bartc wrote: > I can't imagine Python doing anything much 2.5 million times a second. > Just an empty for-loop with 2.5m iterations takes about a second on my > machine. > > Probably it's using some library implemented in C and accessed from > Python. Yes, I believe it is. However, it's still calling back into the Python interpreter to handle callbacks, which is a significant overhead. |