Message56490
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 |
|
| Date |
User |
Action |
Args |
| 2007-10-16 04:05:37 | klaas | set | spambayes_score: 0.00208486 -> 0.00208486 recipients:
+ klaas, loewis, pjdelport, hvbargen |
| 2007-10-16 04:05:37 | klaas | set | spambayes_score: 0.00208486 -> 0.00208486 messageid: <1192507537.66.0.367321336905.issue1663329@psf.upfronthosting.co.za> |
| 2007-10-16 04:05:37 | klaas | link | issue1663329 messages |
| 2007-10-16 04:05:37 | klaas | create | |
|