Perl vs. Python for text manipulation

Jeff Epler jepler at unpythonic.net
Sat Jan 24 19:58:27 CET 2004


On Sat, Jan 24, 2004 at 09:00:17PM +0300, Serge Orlov wrote:
> If not, threads can
> have separate caching. After all, doing I/O on the same file from multipile
> threads is uncommon so it can suffer. 99+ percent of I/O in the world <wink>
> is done from one thread, why should it suffer?

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).

In these cases, Python would either have to hold the GIL during I/O
operations or add its own locking to them (or else decree that file
object access is not thread-safe).  There's no guarantee that this could
be faster than the thread safety already provided in the C library.

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




More information about the Python-list mailing list