RE: Re: Mutable Bytes
"Mark Hahn" <[email protected]> Mon, 26 Jul 2004 23:28:47 -0700
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <000201c473a2$f9ab3620$0d01a8c0@MarkVaio> |
Greg Ewing wrote: > Mark Hahn <[email protected]>: > > > OK, once again my brain was malfunctioning. It was when the def > > keyword was executed that a copy of the function was made, > not when it > > was called. The problem had something to do with executing the def > > more than once. > > It sounds like you need another object here. A Python > function object has just two attributes, a reference to the > function's scope, and a reference to a "code object". The > code object contains the bytecode, plus other info such as > the names of the parameters and local vars. > > The compiler creates the code object, but no function > objects. Each execution of a def statement creates a function > object referencing the appropriate code object and enclosing scope. Just by coincidence, I was planning on seperating the bytecode data out into a separate object for performance reasons as of earlier today. So I will mimic Python as you suggest. Prothon started out a lot simpler that Python. It is getting more and more like Python but I hope only where it really matters.