[Python-Dev] Change PEP 399 import recommendation
Brett Cannon
brett at python.org
Mon Oct 14 17:20:56 CEST 2013
On Sun, Oct 13, 2013 at 3:08 PM, Victor Stinner <victor.stinner at gmail.com>wrote:
> Le 13 oct. 2013 10:19, "Stefan Behnel" <stefan_ml at behnel.de> a écrit :
>
> > I agree. I find it much easier to read a plain and obvious
> >
> > try:
> > from _cmodule import *
> > except ImportError:
> > from _pymodule import *
> >
> > in a facade module ...
>
> I miss maybe something. I don't understand why you would like to use the
> Python implementation if a C implementation is available and probably
> (much) faster.
>
> Maybe developers of PyPy, IronPython and Jython appreciate our effort to
> provide a Python implementation which is up to date and well tested. But
> why should we pay a price (bad performance) if the module is not (never?
> who uses _pyio?) used in CPython. If another Python uses it, the file can
> be renamed (ex: _pyio.py becomes simply io.py).
>
Because doing a rename like that is a deviation between implementations
that saves you nothing more than a file with four lines. And "bad
performance" in this instance is a single import * which in the grand
scheme of things is cheap, especially in this instance where the module is
not on the critical path (and even if it was I would argue it isn't worth
worrying about).
> IMO if the C module is complete (has no extra functions in the "facade"
> module), it should get the main name (ex: decimal, not _decimal).
>
Why? It's not the reference implementation as that's the pure Python
version, but your suggested naming scheme purports the opposite.
-Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131014/5660c853/attachment-0001.html>
More information about the Python-Dev
mailing list