[Python-Dev] [ python-Patches-876206 ] scary frame speed
hacks
Phillip J. Eby
pje at telecommunity.com
Tue Mar 2 20:31:39 EST 2004
At 01:29 PM 3/3/04 +1300, Greg Ewing wrote:
>Tim Peters <tim.one at comcast.net>:
>
> > BTW, if a gazillion distinct functions run when starting up a large app, do
> > we hang on to the memory for their gazillion distinct frames forever?
>
>If you have a gazillion distinct functions in memory at
>once, you've got a gazillion code objects, plus associated
>function objects, arg name tuples, etc... Adding a stack
>frame to each of these probably won't make a huge difference,
>relatively speaking.
Frames are over three times larger than a function and a code object put
together:
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>> import types
>>> types.FrameType.__basicsize__
336
>>> types.FunctionType.__basicsize__
40
>>> types.CodeType.__basicsize__
64
Of course, this doesn't include the bytecode length, but bytecode is quite
compact.
More information about the Python-Dev
mailing list