[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-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 -

[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

[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 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 Christian Heimes
Christian Heimes added the comment: You could raise an error and wait until somebody files a complain. :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___

[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-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: +1 This seems like a reasonable solution. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___ ___

[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

[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 ba...@python.org: -- nosy: +barry ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___ ___ 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 rep...@bugs.python.org http://bugs.python.org/issue9548

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

2013-10-09 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: Added file: http://bugs.python.org/file32025/bootlocale2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___

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

2013-10-09 Thread Eric Snow
Changes by Eric Snow ericsnowcurren...@gmail.com: -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___ ___ Python-bugs-list

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

2012-07-22 Thread Florent Xicluna
Changes by Florent Xicluna florent.xicl...@gmail.com: -- nosy: +flox ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___ ___ Python-bugs-list

[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 arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___

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

2012-05-16 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- stage: - patch review versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___

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

2012-05-16 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com 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

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

2010-08-14 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com 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

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

2010-08-14 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com 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)' built-in function heapify $ cat |

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

2010-08-14 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr 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

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

2010-08-14 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: Nick Coghlan wrote: Nick Coghlan ncogh...@gmail.com 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

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

2010-08-14 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___ ___ Python-bugs-list

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

2010-08-13 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___ ___ Python-bugs-list mailing

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

2010-08-11 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: Antoine Pitrou wrote: Antoine Pitrou pit...@free.fr 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

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

2010-08-11 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr 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

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

2010-08-10 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com 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

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

2010-08-10 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr 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

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

2010-08-10 Thread STINNER Victor
STINNER Victor victor.stin...@haypocalc.com 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

[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 pit...@free.fr: Consider the two following commands, from an SVN working copy: $ ./python -c 'import heapq; print(heapq.heapify)' built-in function heapify $ cat | ./python -c 'import heapq; print(heapq.heapify)' function heapify at 0x7f5d456025a0 In the

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

2010-08-09 Thread Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +lemburg, orsenthil, rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___ ___

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

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr 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 Mark Dickinson
Changes by Mark Dickinson dicki...@gmail.com: -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___ ___ Python-bugs-list

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

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr 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 Antoine Pitrou
Changes by Antoine Pitrou pit...@free.fr: Removed file: http://bugs.python.org/file18454/bootlocale.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___

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

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr 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 ). --

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

2010-08-09 Thread Brett Cannon
Changes by Brett Cannon br...@python.org: -- nosy: +brett.cannon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9548 ___ ___ Python-bugs-list

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

2010-08-09 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: Antoine Pitrou wrote: Antoine Pitrou pit...@free.fr 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

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

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr 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

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

2010-08-09 Thread Marc-Andre Lemburg
Marc-Andre Lemburg m...@egenix.com added the comment: Antoine Pitrou wrote: Antoine Pitrou pit...@free.fr 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

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

2010-08-09 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr 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,

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

2010-08-09 Thread Brett Cannon
Brett Cannon br...@python.org 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