[Python-Dev] Inherance of file descriptor and handles on Windows (PEP 446)

Guido van Rossum guido at python.org
Sat Jul 27 00:12:18 CEST 2013


On Fri, Jul 26, 2013 at 5:08 AM, Victor Stinner
<victor.stinner at gmail.com> wrote:
> After having written 2 PEP on the topic, I slowly agree that make all
> file descriptors non-inheritable is the best *compromise*. It solves
> most, or all, issues.

Right.

> The main drawback is the additionnal syscalls: on some platforms, 2
> additional syscalls are need to make a file descriptor non-inheritable
> for each creation of file descriptor. According to my benchmark on the
> implementation of the PEP 433: the overhead of making a file
> descriptor non-inheritable is between 1% and 3% (7.8 µs => 7.9 or 8.0
> µs) on Linux 3.6.
> http://www.python.org/dev/peps/pep-0433/#performances

Remember that this is going to be Python 3.4 and newer. AFAICT setting
O_CLOEXEC on open works on OSX (at least the man page on OSX 10.8 has
it), on newer Linuxes, and the equivalent on Windows. So even if it
does cost an extra syscall on older systems, those systems will be
obsolete before Python 3.4 becomes mainstream there. And it does look
like the syscalls are pretty cheap. I also don't think I'm not
particularly worried about the cost of syscalls for making a socket
(non)blocking -- although we should probably avoid the second fcntl()
call if the first call shows the flag is already set the way we want
it.

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-Dev mailing list