[Python-3000] python -S

Christian Heimes lists at cheimes.de
Fri Aug 15 02:32:24 CEST 2008


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.

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

Christian



More information about the Python-3000 mailing list