Author lemburg
Recipients brett.cannon, lemburg, mark.dickinson, orsenthil, pitrou, rhettinger, vstinner
Date 2010-08-09.22:04:43
SpamBayes Score 2.51466e-14
Marked as misclassified No
Message-id <4C607B79.2020502@egenix.com>
In-reply-to <1281389418.3173.5.camel@localhost.localdomain>
Content
Antoine Pitrou wrote:
> 
> Antoine Pitrou <pitrou@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
> potentially risk (because of the import lock).

Really ? collections is only used in format_string and can easily
be imported there. Note that putting imports into functions is a technique
to remove problems with import locks - it doesn't create any.

> Furthermore, functools.wraps is used as a decorator at the toplevel of
> locale.py, which makes it currently unremovable.

If you look at the code, that decorator is not needed at all. Furthermore
the whole complication was just introduced to make some tests easier
to write.

> The former is easier said than done, and we may end up writing poor
> man's reimplementations of some stdlib functions.

Please be more specific. The modules that have an impact
on import time are collections, functools and re.

>> It would be worthwhile adding a note to the top of the module
>> mentioning the fact that the module is loaded early on by Python
>> and to warn about use of non-builtin module imports.
> 
> Use of non-builtin stdlib modules is legitimate for many functions which
> aren't used in the startup process anyway. The rationale behind the
> patch is precisely to define a subset that is needed at startup and
> shouldn't rely on stdlib facilities. The rest of the locale module is
> allowed to use whatever stdlib facilities it desires, which is always
> much more practical.

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.

> (note, this is already done elsewhere, for example _abcoll.py or
> _weakrefset.py)

Those are special cases since they are needed for ABCs. locale
is not special enough to warrant such a disruption in module
organization and it's not needed either (see above).
History
Date User Action Args
2010-08-09 22:04:47lemburgsetrecipients: + lemburg, brett.cannon, rhettinger, mark.dickinson, orsenthil, pitrou, vstinner
2010-08-09 22:04:44lemburglinkissue9548 messages
2010-08-09 22:04:43lemburgcreate