Concerning bounded number of classes created
Hey all, Sorry to keep asking questions on the mailing list, but I've been doing my semester research project on PyPy, and my deadline is beginning to loom... I have a question concerning what I think is a conflict between the RPython coding guide and the 2005 EU paper. The paper states: Our approach goes further and analyses live programs in memory: the program is allowed to contain fully dynamic sections, as long as these sections are entered a bounded num- ber of times. For example, the source code of the PyPy interpreter, which is itself written in this bounded-dynamism style, makes extensive use of the fact that it is possible to build new classes at any point in time -- not just during an initialisation phase -- as long as the number of new classes is bounded. For example, interpreter/gateway.py builds a custom wrapper class corresponding to each function that a particular variable can reference. There is a finite num- ber of functions in total, so this can only create a finite number of extra wrapper classes. While the coding guide says: definitions run-time definition of classes or functions is not allowed. I'm I understood the paper correctly, any piece of code can create zero or one class, but not infinity. However, this doesn't seem to jive with what the coding guide says. Alex
2011/12/9 Alexander Golec <alexgolecmailinglists@gmail.com>:
Hey all,
Sorry to keep asking questions on the mailing list, but I've been doing my semester research project on PyPy, and my deadline is beginning to loom...
I have a question concerning what I think is a conflict between the RPython coding guide and the 2005 EU paper. The paper states:
Our approach goes further and analyses live programs in memory: the program is allowed to contain fully dynamic sections, as long as these sections are entered a bounded num- ber of times. For example, the source code of the PyPy interpreter, which is itself written in this bounded-dynamism style, makes extensive use of the fact that it is possible to build new classes at any point in time -- not just during an initialisation phase -- as long as the number of new classes is bounded. For example, interpreter/gateway.py builds a custom wrapper class corresponding to each function that a particular variable can reference. There is a finite num- ber of functions in total, so this can only create a finite number of extra wrapper classes.
I'm not actually sure what this is referring to; it may have changed since 2005.
While the coding guide says:
definitions
run-time definition of classes or functions is not allowed.
This is the truest statement currently. -- Regards, Benjamin
So at no point reachable from the entry_point (or is it run?) of the program can you create classes and functions? Alex On Dec 9, 2011, at 8:18 PM, Benjamin Peterson wrote:
2011/12/9 Alexander Golec <alexgolecmailinglists@gmail.com>:
Hey all,
Sorry to keep asking questions on the mailing list, but I've been doing my semester research project on PyPy, and my deadline is beginning to loom...
I have a question concerning what I think is a conflict between the RPython coding guide and the 2005 EU paper. The paper states:
Our approach goes further and analyses live programs in memory: the program is allowed to contain fully dynamic sections, as long as these sections are entered a bounded num- ber of times. For example, the source code of the PyPy interpreter, which is itself written in this bounded-dynamism style, makes extensive use of the fact that it is possible to build new classes at any point in time -- not just during an initialisation phase -- as long as the number of new classes is bounded. For example, interpreter/gateway.py builds a custom wrapper class corresponding to each function that a particular variable can reference. There is a finite num- ber of functions in total, so this can only create a finite number of extra wrapper classes.
I'm not actually sure what this is referring to; it may have changed since 2005.
While the coding guide says:
definitions
run-time definition of classes or functions is not allowed.
This is the truest statement currently.
-- Regards, Benjamin
2011/12/9 Alexander Golec <alexgolecmailinglists@gmail.com>:
So at no point reachable from the entry_point (or is it run?) of the program can you create classes and functions?
All the classes that there will ever by instances of in the RPython program are known at translation. -- Regards, Benjamin
Also, if you take a look at gateway.py, you can see that type is being called. Does the interpreter treat class definitions and calls to type differently? https://bitbucket.org/pypy/pypy/src/94737f156c30/pypy/interpreter/gateway.py Alex On Dec 9, 2011, at 8:22 PM, Benjamin Peterson wrote:
2011/12/9 Alexander Golec <alexgolecmailinglists@gmail.com>:
So at no point reachable from the entry_point (or is it run?) of the program can you create classes and functions?
All the classes that there will ever by instances of in the RPython program are known at translation.
-- Regards, Benjamin
2011/12/9 Alexander Golec <alexgolecmailinglists@gmail.com>:
Also, if you take a look at gateway.py, you can see that type is being called. Does the interpreter treat class definitions and calls to type differently?
https://bitbucket.org/pypy/pypy/src/94737f156c30/pypy/interpreter/gateway.py
That happens before the flow space sees it. -- Regards, Benjamin
Hi, On Sat, Dec 10, 2011 at 02:16, Alexander Golec <alexgolecmailinglists@gmail.com> wrote:
I have a question concerning what I think is a conflict between the RPython coding guide and the 2005 EU paper.
This is not a conflict. The coding guide says that you cannot create any RPython class at runtime. This is true. A priori you would think that this means that all RPython classes must be created before we translate the program, but not exactly: as the 2005 EU paper says, you can create (a bounded number of) extra RPython classes *during* translation, more precisely during annotation (and not only *before* translation starts), using tricks like specialize:memo functions. Once annotation finishes, no more RPython class can be created. A bientôt, Armin.
participants (3)
-
Alexander Golec
-
Armin Rigo
-
Benjamin Peterson