[Python-Dev] inspect.py very slow under 2.5
Ralf Schmitt
ralf at brainbot.com
Wed Sep 6 12:14:09 CEST 2006
Fernando Perez wrote:
>
> These enormous numbers of calls are the origin of the slowdown, and the more
> modules have been imported, the worse it gets.
--- /exp/lib/python2.5/inspect.py 2006-08-28 11:53:36.000000000 +0200
+++ inspect.py 2006-09-06 12:10:45.000000000 +0200
@@ -444,7 +444,8 @@
in the file and the line number indexes a line in that list. An
IOError
is raised if the source code cannot be retrieved."""
file = getsourcefile(object) or getfile(object)
- module = getmodule(object)
+ #module = getmodule(object)
+ module = None
if module:
lines = linecache.getlines(file, module.__dict__)
else:
The problem seems to originate from the module=getmodule(object) in
findsource. If I outcomment that code (or rather do a module=None),
things seem to be back as normal. (linecache.getlines has been called
with a None module in python 2.4's inspect.py).
- Ralf
More information about the Python-Dev
mailing list