[issue1663329] subprocess/popen close_fds perform poor if SC_OPEN_MAX is hi
Mike Klaas
report at bugs.python.org
Tue Oct 16 06:05:37 CEST 2007
Mike Klaas added the comment:
This problem has also afflicted us.
Attached is a patch which adds closerange(fd_low, fd_high) to the posix
(and consequently os) module, and modifies subprocess to use it. Patch
is against trunk but should work for 2.5maint.
I don't really think that this is useful enough to add to the public
api, but it results in a huge performance benefit for subprocess:
[python-trunk]$ ./python -m timeit -s 'import python_close'
'python_close.go(100000)'
10 loops, best of 3: 358 msec per loop
[python-trunk]$ ./python -m timeit -s 'import os' 'os.closerange(4,
100000)'
10 loops, best of 3: 20.7 msec per loop
[python-trunk]$ ./python -m timeit -s 'import python_close'
'python_close.go(300000)'
10 loops, best of 3: 1.05 sec per loop
[python-trunk]$ ./python -m timeit -s 'import os' 'os.closerange(4,
300000)'10 loops, best of 3: 63 msec per loop
[python-trunk]$ cat python_close.py
import os, sys
def go(N):
for i in xrange(4, N):
try:
os.close(i)
except:
pass
----------
nosy: +klaas
_____________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1663329>
_____________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: posix_closerange.patch
Type: application/octet-stream
Size: 1915 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-bugs-list/attachments/20071016/e59cde84/attachment.obj
More information about the Python-bugs-list
mailing list