diff options
author | Guido van Rossum <guido@python.org> | 1997-01-24 04:00:21 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-01-24 04:00:21 (GMT) |
commit | 747596a4917cc8924519bdee081a894ebcb0e059 (patch) | |
tree | 5bcce52523f914e7057fc9396df2c56fc1d4f293 /Objects | |
parent | 463e55a9165bd43442e0f7ee27370cba2bc3066d (diff) | |
download | cpython-747596a4917cc8924519bdee081a894ebcb0e059.zip cpython-747596a4917cc8924519bdee081a894ebcb0e059.tar.gz cpython-747596a4917cc8924519bdee081a894ebcb0e059.tar.bz2 |
When a recycled frame has more local+stack slots than needed,
give the extra slots to the stack rather than than forgetting about
them (this reduces the number of reallocs done).
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/frameobject.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 79757e9..ae962e9 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -172,6 +172,8 @@ newframeobject(back, code, globals, locals) if (f == NULL) return (PyFrameObject *)err_nomem(); } + else + extras = f->f_nlocals + f->f_stacksize; f->ob_type = &Frametype; NEWREF(f); } @@ -203,11 +205,11 @@ newframeobject(back, code, globals, locals) f->f_trace = NULL; f->f_lasti = 0; - f->f_lineno = -1; + f->f_lineno = code->co_firstlineno; f->f_restricted = (builtins != getbuiltindict()); f->f_iblock = 0; f->f_nlocals = code->co_nlocals; - f->f_stacksize = code->co_stacksize; + f->f_stacksize = extras - code->co_nlocals; while (--extras >= 0) f->f_localsplus[extras] = NULL; |