[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-12-16 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
resolution:  - wont fix
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-12-12 Thread STINNER Victor

STINNER Victor added the comment:

The real question for me is: why are you interested in speeding up the
import of the operator module? 200 µs won't make a visible difference.

Alone, the gain is useless, but it's like the work done in Python 3.4 to avoid 
loading some modules at startup. The overall idea is to have a fast startup 
time.

I heard that Python 3 startup time is a major blocker point for Mercurial for 
example.

But maybe this specific issue is not worth the trouble. (Other parts should be 
optimized.)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-29 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Why not:


try:
from _operator import *
except ImportError:
from _pyoperator import *

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-29 Thread STINNER Victor

STINNER Victor added the comment:

 Why not:
 
 try:
 from _operator import *
 except ImportError:
 from _pyoperator import *

Let's try (I replaced operator.py with these 4 lines).

$ ./python -m timeit import sys; modname='operator' __import__(modname); del 
sys.modules[modname]; del sys.modules['_operator'] 
1 loops, best of 3: 165 usec per loop

$ ./python -m timeit import sys; modname='operator' __import__(modname); del 
sys.modules[modname] 
1 loops, best of 3: 136 usec per loop

import operator is only 2x faster (289 usec = 136 usec). It's less 
interesting. And what would be the purpose of a file of 4 line which containing 
import *? Do you think that PyPy, IronPython and Jython will reuse such 
trampoline/wrapper?

--
type:  - performance

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-29 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 import operator is only 2x faster (289 usec = 136 usec). It's less
 interesting.

The real question for me is: why are you interested in speeding up the
import of the operator module? 200 µs won't make a visible difference.

 And what would be the purpose of a file of 4 line which
 containing import *?

To make it obvious that there are two implementations, one of which is
a fallback.

--
title: operator.py: move the Python implementation in the else block of 
try/except ImportError - operator.py: move the Python implementation in the 
else   block of try/except ImportError

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-29 Thread Stefan Krah

Stefan Krah added the comment:

I understand the desire to speed things up, but either the four-line facade
module or else a single module is probably required by PEP-399.

--
title: operator.py: move the Python implementation in the else  block of 
try/except ImportError - operator.py: move the Python implementation in the 
else block of try/except ImportError

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-28 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


Added file: http://bugs.python.org/file32404/builtin_operator_diff.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-28 Thread STINNER Victor

STINNER Victor added the comment:

 Another option is to add a _pyoperator module.

Attached builtin_operator.patch patch implements this option: operator.c 
becomes the main operator module, _pyoperator is the pure Python implementation 
(don't use from _operator import * anymore).

With the patch:

$ ./python -m timeit import sys; modname='_pyoperator' __import__(modname); 
del sys.modules[modname] 
1000 loops, best of 3: 276 usec per loop

$ ./python -m timeit import sys; modname='operator' __import__(modname); del 
sys.modules[modname] 
1 loops, best of 3: 22.7 usec per loop


The patch is huge because files are renamed: see builtin_operator_diff.patch 
for the diff.

--
keywords: +patch
Added file: http://bugs.python.org/file32403/builtin_operator.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-28 Thread STINNER Victor

STINNER Victor added the comment:

Without the patch:

$ ./python -m timeit import sys; modname='operator' __import__(modname); del 
sys.modules[modname] 
1000 loops, best of 3: 289 usec per loop

$ ./python -m timeit import sys; modname='_operator' __import__(modname); 
del sys.modules[modname] 
1 loops, best of 3: 21.4 usec per loop


import operator is 12.7x faster (289 usec = 22.7 usec) with 
builtin_operator.patch.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-18 Thread Zachary Ware

Changes by Zachary Ware zachary.w...@gmail.com:


--
nosy: +zach.ware

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-13 Thread Stefan Krah

Stefan Krah added the comment:

To be fair, for the startup time I can't really detect any difference between 
importing _operator directly and the current setup.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-13 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-12 Thread Stefan Krah

Stefan Krah added the comment:

Using the microbenchmark I get (standard version):

./python -m timeit import sys; modname='operator' __import__(modname); del 
sys.modules[modname]
1000 loops, best of 3: 460 usec per loop


Victor's version:

./python -m timeit import sys; modname='operator' __import__(modname); del 
sys.modules[modname]
1000 loops, best of 3: 355 usec per loop


Importing _operator directly:

./python -m timeit import sys; modname='_operator' __import__(modname); del 
sys.modules[modname]
1 loops, best of 3: 35.7 usec per loop


Extrapolating from what I did with decimal, I guess a _pyoperator
version could get down to something like 70 usec.

--
nosy: +skrah

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19229] operator.py: move the Python implementation in the else block of try/except ImportError

2013-10-11 Thread STINNER Victor

New submission from STINNER Victor:

To speedup Python startup, it may be interesting to not create useless many 
functions and classes in operator.py: from _operator import * will remove 
them a few line later.

What do you think of moving the Python implementation of the operator module 
inside in the else block of try/except ImportError section?

See attached operator.py for an example.

It adds an ugly level of indentation, but it's for performances!

Another option is to add a _pyoperator module.

--
files: operator.py
messages: 199525
nosy: christian.heimes, haypo
priority: normal
severity: normal
status: open
title: operator.py: move the Python implementation in the else block of 
try/except ImportError
versions: Python 3.4
Added file: http://bugs.python.org/file32053/operator.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue19229
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com