A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-September/068666.html below:

[Python-Dev] inspect.py very slow under 2.5

[Python-Dev] inspect.py very slow under 2.5 [Python-Dev] inspect.py very slow under 2.5Nick Coghlan ncoghlan at gmail.com
Wed Sep 6 15:06:33 CEST 2006
Ralf Schmitt wrote:
> Nick Coghlan wrote:
>>
>> It looks like the problem is the call to getabspath() in getmodule(). 
>> This happens every time, even if the file name is already in the 
>> modulesbyfile cache. This calls os.path.abspath() and 
>> os.path.normpath() every time that inspect.findsource() is called.
>>
>> That can be fixed by having findsource() pass the filename argument to 
>> getmodule(), and adding a check of the modulesbyfile cache *before* 
>> the call to getabspath().
>>
>> Can you try this patch and see if you get 2.4 level performance back 
>> on Fernando's test?:
> 
> no. this doesn't work. getmodule always iterates over 
> sys.modules.values() and only returns None afterwards.
> One would have to cache the bad file value, or only inspect new/changed 
> modules from sys.modules.

Good point. I modified the patch so it does the latter (it only calls 
getabspath() again for a module if the value of module.__file__ changes).

Cheers,
Nick.


-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4