[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: Here normal_startup and startup_nosite wouldn't show a difference (under Linux anyway) because the locale module is only imported for non-interactive streams, AFAICT. -- resolution: -> fixed stage: patch review -> committed/rejected status: open -> cl

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-12 Thread Brett Cannon
Brett Cannon added the comment: Just a quick favour to ask people: please post benchmark numbers of startup_nosite and normal_startup with your patches, otherwise we are taking stabs in the dark that the code complexity being suggested is worth it. -- _

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-11 Thread Roundup Robot
Roundup Robot added the comment: New changeset fbbf8b160e8d by Antoine Pitrou in branch 'default': Issue #9548: Add a minimal "_bootlocale" module that is imported by the _io module instead of the full locale module. http://hg.python.org/cpython/rev/fbbf8b160e8d -- nosy: +python-dev __

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-11 Thread Christian Heimes
Christian Heimes added the comment: You could raise an error and wait until somebody files a complain. :) -- ___ Python tracker ___ ___

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-11 Thread STINNER Victor
STINNER Victor added the comment: "Does anyone know if Python does still support systems where CODESET is not available? Which OS does not support CODESET?" I checked my VMs with Python, nl_langinfo(CODESET) works on: - Linux (Fedora 18, kernel 3.9) - OpenBSD 5.2 - OpenIndiana 148 (SunOS 5.11)

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-11 Thread STINNER Victor
STINNER Victor added the comment: > ... the _bootlocale can be simplified to a few lines: ... Here is the patch implementing my proposition: bootlocale3.patch. -- Added file: http://bugs.python.org/file32050/bootlocale3.patch ___ Python tracker

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-11 Thread Christian Heimes
Christian Heimes added the comment: The locale module uses only collections.abc.Mapping. The import of the entire collections module can be avoided if collections.abc is renamed to _abcoll again. functools.wrap() can be replaced with: localeconv.__doc__ = _localeconv.__doc__ The other attribu

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-10 Thread STINNER Victor
STINNER Victor added the comment: The io module doesn't need to set temporarly the LC_CTYPE locale (which is a good thing because the change is process-wide!). If we ignore systems where CODESET is not available, the _bootlocale can be simplified to a few lines: if sys.platform.startswith("win

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-09 Thread Raymond Hettinger
Raymond Hettinger added the comment: +1 This seems like a reasonable solution. -- ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-09 Thread Eric Snow
Changes by Eric Snow : -- nosy: +eric.snow ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.o

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-09 Thread Antoine Pitrou
Changes by Antoine Pitrou : Added file: http://bugs.python.org/file32025/bootlocale2.patch ___ Python tracker ___ ___ Python-bugs-list mailing

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: Updated patch for 3.4. -- nosy: +benjamin.peterson, christian.heimes versions: +Python 3.4 -Python 3.3 ___ Python tracker ___ ___

[issue9548] locale can be imported at startup but relies on too many library modules

2013-10-09 Thread Barry A. Warsaw
Changes by Barry A. Warsaw : -- nosy: +barry ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python

[issue9548] locale can be imported at startup but relies on too many library modules

2012-07-22 Thread Florent Xicluna
Changes by Florent Xicluna : -- nosy: +flox ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue9548] locale can be imported at startup but relies on too many library modules

2012-05-17 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscrib

[issue9548] locale can be imported at startup but relies on too many library modules

2012-05-16 Thread STINNER Victor
STINNER Victor added the comment: > initializing the standard streams imports Lib/locale.py It looks like only locale.getpreferredencoding() is needed to initialize standard streams. Another option is to add a locale encoding codec. I already proposed the idea in #13619 but it was rejected.

[issue9548] locale can be imported at startup but relies on too many library modules

2012-05-16 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- stage: -> patch review versions: +Python 3.3 -Python 3.2 ___ Python tracker ___ ___ Python-bugs-list ma

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-14 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +eric.araujo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-14 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Nick Coghlan wrote: > > Nick Coghlan added the comment: > > As we move more and more infrastructure into Python code, we're going to see > this pattern (i.e. a bootstrap module underlying the real module) more and > more often (e.g. I seem to recall Bre

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-14 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Can we close this issue, or do you consider that it is still very > important to not load too much modules at startup? The patch eases the bootstrap constraints by creating a bootstrap-friendly subset of locale.py. It is indeed much less pressing now that the

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-14 Thread STINNER Victor
STINNER Victor added the comment: Antoine fixed #9589 by rewriting site.py code in C and calling it more much earlier: r83988. This commit fixes the initial problem of this issue: $ ./python -c 'import heapq; print(heapq.heapify)' $ cat | ./python -c 'import heapq; print(heapq.heapify)' Ca

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-14 Thread Nick Coghlan
Nick Coghlan added the comment: As we move more and more infrastructure into Python code, we're going to see this pattern (i.e. a bootstrap module underlying the real module) more and more often (e.g. I seem to recall Brett has to do something similar when playing with the pure Python __impor

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-13 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +ncoghlan ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-11 Thread Antoine Pitrou
Antoine Pitrou added the comment: > No, what I'm proposing is to make "import locale" safe during > boot time. By separating out some functions into a separate > module which is then supposed to be used by the boot process, > you don't really solve the problem. I do, and my experimentations sho

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-11 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Antoine Pitrou wrote: > > Antoine Pitrou added the comment: > >> I said "warn about the use of non-builtin modules", not disallow >> their use. AFAIK, the purpose of the exercise is to reduce the >> number of non-builtin modules being loaded early on duri

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-10 Thread STINNER Victor
STINNER Victor added the comment: > Indeed, but since it calls sysconfig.get_platform(), I'm not sure how > much code would need to be rewritten in C. Oh, the function is prefixed by the following comment: # XXX This should not be part of site.py, since it is needed even when # using the -S op

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-10 Thread Antoine Pitrou
Antoine Pitrou added the comment: > > heapq tries to import _heapq but, at this point, the build dir > > (such as "build/lib.linux-x86_64-3.2/") hasn't been added to sys.path > > The problem only exists for developers, not for an installation copy > of Python? This particular problem indeed (

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-10 Thread STINNER Victor
STINNER Victor added the comment: > heapq tries to import _heapq but, at this point, the build dir > (such as "build/lib.linux-x86_64-3.2/") hasn't been added to sys.path The problem only exists for developers, not for an installation copy of Python? Another approach is to call required site

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Brett Cannon
Brett Cannon added the comment: Just to comment on the import lock issue when importing from within a function, it is a problem. If an import triggers the launching of a thread which calls these functions that have an import inside of them, deadlock will occur. This has been reported as an is

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I said "warn about the use of non-builtin modules", not disallow > their use. AFAIK, the purpose of the exercise is to reduce the > number of non-builtin modules being loaded early on during > Python startup. The purpose of the exercise is to avoid, as much a

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Antoine Pitrou wrote: > > Antoine Pitrou added the comment: > >> I don't think that's the right way forward. >> >> It's much easier to either remove the need to import those >> extra modules or defer their import to actual use within >> a function. > > T

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: > I don't think that's the right way forward. > > It's much easier to either remove the need to import those > extra modules or defer their import to actual use within > a function. The latter has various issues, such as being overly tedious and potentially ri

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Antoine Pitrou wrote: > > Antoine Pitrou added the comment: > > Attached patch fixes the issue by creating a separate "_bootlocale" module, > used at bootstrap, which doesn't import collections, functools and friends. I don't think that's the right way

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Brett Cannon
Changes by Brett Cannon : -- nosy: +brett.cannon ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: Chances are that the patch will also fix the test_heapq failures on some buildbots (see e.g. http://www.python.org/dev/buildbot/3.x/builders/x86%20Tiger%203.x/builds/759/steps/test/logs/stdio ). -- ___ Python trac

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Antoine Pitrou
Changes by Antoine Pitrou : Removed file: http://bugs.python.org/file18454/bootlocale.patch ___ Python tracker ___ ___ Python-bugs-list mailing

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: Updated patch also replaces imports of locale in site.py (since it can be imported early on startup). -- Added file: http://bugs.python.org/file18455/bootlocale.patch ___ Python tracker

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Mark Dickinson
Changes by Mark Dickinson : -- nosy: +mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou added the comment: Attached patch fixes the issue by creating a separate "_bootlocale" module, used at bootstrap, which doesn't import collections, functools and friends. -- keywords: +patch Added file: http://bugs.python.org/file18454/bootlocale.patch _

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +lemburg, orsenthil, rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue9548] locale can be imported at startup but relies on too many library modules

2010-08-09 Thread Antoine Pitrou
New submission from Antoine Pitrou : Consider the two following commands, from an SVN working copy: $ ./python -c 'import heapq; print(heapq.heapify)' $ cat | ./python -c 'import heapq; print(heapq.heapify)' In the second case, the "from _heapq import *" in heapq fails silently. The reason