Speed of Python vs. Perl
Fredrik Lundh
fredrik at effbot.org
Fri Jan 12 02:39:26 EST 2001
Tim Peters wrote:
> Unless you've got a broken installation, Python shouldn't be spending *any*
> time parsing imported files at startup.
well, isn't "unmarshalling" a form of parsing?
(read token, figure out what it means, update data structure, repeat
until end of data)
note that unmarshal uses lots of getc calls, and we all know what that
means for performance... how about changing read_compiled_module()
from
co = PyMarshal_ReadObjectFromFile(fp);
to something like:
size = getsize(fp)
if size could be determined, and is less than 200k:
buf = malloc(size)
fread(buf, 1, size, fp)
co = PyMarshal_ReadObjectFromString(buf, size)
free(buf)
else:
co = PyMarshal_ReadObjectFromFile(fp);
Cheers /F
More information about the Python-list
mailing list