Is Python really slow?
Tim Rowe
digitig at cix.co.uk
Sat May 27 18:32:00 EDT 2000
In article <8gp0fh$2g4$1 at newsg4.svr.pol.co.uk>,
mak at imakhno.freeserve.co.uk (Makhno) wrote:
> >>> Does xrange create an array of numbers 1...1e8?
> >>
> >> Yes, it does
> >>
> >No, it doesn't.
>
> Well, if it did create an array Matlab-style, then that would account
> for
> why the C routine was faster.
But it doesn't. That's the difference between range and xrange.
But Python /is/ interpreted, so I wouldn't expect it to be as fast as C.
In fact, there tends to be a tradeoff between the implementation time and
the run time. The Python literature says implement time-critical bits in
C, the C literature says implement the time-critical bits in assembler,
some assembly programmers hand-craft critical machine code, and you could
always design and fabricate your own chips :-)
More information about the Python-list
mailing list