[Python-3000] python -S

Brett Cannon brett at python.org
Fri Aug 15 05:47:58 CEST 2008


On Thu, Aug 14, 2008 at 5:32 PM, Christian Heimes <lists at cheimes.de> wrote:
> Antoine Pitrou wrote:
>>
>> I feel stupid for not thinking of such an obvious solution.
>> (by the way, is _thread always available?)
>
> _thread is a builtin module. It's available on every platform that supports
> threading (which should be all platforms we support). If you want to be
> extra carefully then use _dummy_thread as a fallback.
>
> try:
>    from _thread import allocate_lock as Lock
> except ImportError:
>    from _dummy_thread import allocate_lock as Lock
>
> By the way I did some testing. We could save the load of the re and couple
> of sre_* modules by rewriting a tiny bit of linecache. The linecache module
> is using re to find the "# coding: spec" of a Python source file when the
> load fails to return the source of a file. It'd reduce the amount of loaded
> modules by 5.
>

Speaking with my importlib hat on, I need a function that can easily
return the encoding of a file, so I have another legit use-case for
the functionality where exposing it through some built-in fashion
would be REALLY appreciated (I have one hacked together as
imp.source_open() in my bootstrapping work, but I still don't think it
is a very good solution).

> Remove "import types" from warnings.py and you'll get one for free.

Who is loading 'warnings'? If it something minor and very
startup-specific, perhaps using _warnings instead is a possibility.

-Brett


More information about the Python-3000 mailing list