Perl vs. Python for text manipulation

Tim Peters tim.one at comcast.net
Sat Jan 24 22:38:46 CET 2004


[Jeff Epler]
> The "unlocked I/O" mentioned earlier refers to locking inside the
> standard C library, so Python can't avoid it except by calling
> non-portable functions such as getc_unlocked* or by using lower-level
> I/O primitives such as posix read(2)/write(2).

Current Pythons do use getc_unlocked() on platforms that have it.

...

> * Actually, my getc_unlocked() manpage says that the function is in
>   POSIX.1, so this may be as portable as read/write would be

Alas, it isn't.  Python uses read()/write() on all platforms (there is no
known Python platform that doesn't supply them).  getc_unlocked() is rarer.
See fileobject.c for the dreadful hack used if getc_unlocked() isn't
available (but, hack or not, on some platforms that's faster than using
getc_unlocked; there are #defines you can play with to try it both ways).





More information about the Python-list mailing list