On Thu, Aug 14, 2008 at 5:32 PM, Christian Heimes <[EMAIL PROTECTED]> 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 _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com