loop in python

bruno modulix onurb at xiludom.gro
Tue Aug 23 06:35:51 EDT 2005


km wrote:
>>If you want a fast language, try Holden. I've just invented it. 
>>Unfortunately it gets the answer to every problem wrong unless the 
>>answer is 42, but boy it runs quickly. The code for the whole 
>>interpreter (it's written in Python) follows:
> 
> 
>>print 42
> 
> 
> great ! u can use it for ur own projects. but pls donot suggest it to
anyone else.

<ot>
If you hope to be taken seriously, please abandon the sms-talk style here.
</ot>

> anyway improve it - its quite buggy now :-D

Nope, it works just as described. "It's not a bug, Sir, it's a feature" !-)

> 
>>Speed of execution is so insignificant for the majority of programming problems 
> 
> I donot agree with that.
> If thats the case then no one would be using C or C++ etc for instance.

1/ "for the majority of programming problems" : "the majority", not "all
and every".
2/ Apache is coded in C, but there are cases where it can be
outperformed by a specializd Python-coded HTTP server.
3/ OpenOffice is coded in C++ and it's one of the slowest app I ever saw
(even Photoshop 6 on a dying P133/32mo Win98 box is more responsive)

In most systems, the parts that can be performance bottlenecks are the
presentation  and the data persistence layers. That's the parts that are
*already* coded in low-level languages and optimized as can be - if of
course you use existing tools (GUI Toolkit, RDBMS etc) instead of trying
to reimplement'em in Perl/Python/whatever !-)

> one important thing is that i am not comparing python with C but with 
similar language, Perl.

What you are "comparing" is either IO times (the "print loop" program),
where Perl beats C - which means that Perl's IO have been written at a
very low level instead of relying on the stdlib's IO - or absolutely
meaningless (I just don't care if no-op loops are slow since I don't
write no-op loops).

> well ofcourse i dont jump into conclusion,

Yes you did.

> just
with just a simple 'loops' snippet, that python is slower than perl.

for i in xrange(100000):
  print "this 'benchmark' is ABSOLUTELY MEANINGLESS"


> but
when speed is important then ? also i hate people recommending "if u
need speed code it as a C extension module". ofcourse i donot expect
pure python/perl program to execute at the speed of a C program.

In some cases, they can be fastest than the C version.

> 
>>that this obsession reveals a certain inexperience.
> 
> 
> its neither obsession nor inexperience ... its just the requirement. 

Which "requirement" ?

> i think less buggy code is not the main concern for all.

+1 QOTW

> i am aware one of the main principle python isn founded is better
readability but is that a feature which decreases execution speed ?

Nope. It has to do with implementation (of the language), not design.

> there obviously will be a bias
in this list towards python

Oh, really ? Err, wait, what's the name of this group, exactly ?

> but i need a honest opinion of python vs
perl. (especially when it comes to webscripting)

This is another question, and has nothing to do with your "benchmark",
but FWIW, Google uses Python, not Perl.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list