Is Python overhyped (just like Java)?
Alex Martelli
aleax at aleax.it
Tue Apr 1 04:26:32 EST 2003
David Abrahams wrote:
>> Also, "read all the lines from a file" is not a primitive in Python -
>> it's a method call ... *and* it is written in C.
>
> That's what I mean by "a primitive". All of Python is written in C,
> so that's as primitive as things get. "Read all the lines from a
> file" can be specifically optimized for Python, whereas when you write
> the "obvious" code for it in C++, you're probably seeing overheads
> which reflect, e.g., buffering which makes sense for general-purpose
> I/O but which is a waste when reading all lines from a file.
Yeah, but as you'll see in my code in the other post I wasn't using
readlines anyway -- just looping on the file, i.e. reading a line at
a time with buffering. That's pretty close to the loop calling
getline I have in the C++ version, one would hope.
>> Obviously there could be as good an implementation in C++ on the
>> same platform - whether there could be a *better* implementation is
>> another question.
>
> And another question is whether there could be a better
> implementation *for that particular job*.
Sure! Hey, 2 minutes' twiddling with the Python code (not even
bothering to profile etc, just on general principles) already
speeded it up a lot -- of course there must be even speedier ways.
Nor did I ever claim otherwise!
Alex
More information about the Python-list
mailing list