BASIC or Python?

Mirko Liss mirko.liss at web.de
Wed Jul 11 04:12:00 EDT 2001


> On Tue, 10 Jul 2001 02:17:31 GMT, Gerry Quinn <gerryq at indigo.ie> wrote:
> >>>> for n in range(2, 10):
> >..     for x in range(2, n):
> >..         if n % x == 0:
> >..            print n, 'equals', x, '*', n/x
> >..            break
> >..     else:
> >..          print n, 'is a prime number'
> >.. 
> >
> >Now some people may very well find that lovable, but I certainly don't.  
> >Note how the clever language design means that the 'else' must be 
> >level-indented with the 'for'.   No doubt longer programs are even more 

You expect the 'else' being level indented with the 'if' conditional,
don't you?

Well, it's not an 'if...else' structure but a 'for...else' structure.
The 'else' clause will be skipped if you leave the 'for' loop
with 'break'.

There are several weird things in Python, but this isn't one
of those. I suppose there's no perfect language. 

> >fun.  The FAQ on increasing speed helpfully notes that function calls 
> >are expensive...
You can write slow code in C and fast programs in Python.
Speed often depends on the algorithm. And C programmers
tend to write simpler code.

Python is often very slow, though. Maybe you should try Perl.
I used logfile analyzers in Perl and Python (radiusreport and
radiuscontext) and the perl program was much faster.
But it used up much memory. When working with large logfiles,
memory quickly got exhausted. The other analyzer needed
less memory. I think that's because Python often copies a
reference and not the actual data. Not wanting to use the 
swap partition all the time, I switched to the python code.
Maybe I should have tried and optimized the perl program.

This is just an example, not a benchmark. So don't draw
general conclusions. 

On Tue, 10 Jul 2001, phil hunt wrote:
> I don't wish you to know either. Python is far too sensible a
> language for the likes of you to be using it.

I remember you being a very nice and helpful person, Phil.
Too much coffee ?


Friendly regards,

Mirko Liss




More information about the Python-list mailing list