Message60676
We start with a boring example.
>>> import profile
>>> profile.Profile().runctx('print len',{},{})
<built-in function len>
<profile.Profile instance at 0x3c9ccd8>
No news here. But if we do exactly the same using hotshot, we
get:
>>> import hotshot
>>> hotshot.Profile('/tmp/hs').runctx('print len',{},{})
Traceback (most recent call last):
File "<input>", line 1, in ?
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/
python2.4/hotshot/__init__.py", line 65, in runctx
self._prof.runcode(code, globals, locals)
File "<string>", line 1, in ?
NameError: name 'len' is not defined
The following workaround works:
>>> hotshot.Profile('/tmp/hs').runctx('print len',{'__builtins__':
__builtins__},{})
<built-in function len>
<hotshot.Profile instance at 0x3cba6e8>
But I don't believe this is the way hotshot is supposed to work.
This is on Mac Python, IDE, both 2.3 and 2.4, but I think that
doesn't matter at all!
- Jurjen |
|
Date |
User |
Action |
Args |
2008-01-20 09:57:33 | admin | link | issue1149798 messages |
2008-01-20 09:57:33 | admin | create | |
|