[pypy-svn] rev 1100 - pypy/trunk/doc

lac at codespeak.net lac at codespeak.net
Mon Jul 7 17:21:00 CEST 2003


Author: lac
Date: Mon Jul  7 17:21:00 2003
New Revision: 1100

Modified:
   pypy/trunk/doc/oscon2003-paper.txt
Log:
More changes.  Getting more tolerable.


Modified: pypy/trunk/doc/oscon2003-paper.txt
==============================================================================
--- pypy/trunk/doc/oscon2003-paper.txt	(original)
+++ pypy/trunk/doc/oscon2003-paper.txt	Mon Jul  7 17:21:00 2003
@@ -66,6 +66,14 @@
 Terminology (a short digression)
 ********************************
 
+In PyPy there is a distinction between **application level code**, which
+is the world that PyPy is interpreting, and which can use the full features 
+of the language, and the **interpreter level code** which is the world
+that CPython is interpreting.  This needs to be written in a subset of Python.
+(Currently you are mainly restricted to immutable objects; no dicts, you can
+use globals but you cannot modify them.  *What defines Restricted Python?*
+is a matter of current debate.
+
 In a Python-like language, a running interpreter has three main parts:
   
   * the main loop, which suffles data around and calls the operations defined in the object library according to the bytecode.
@@ -96,6 +104,7 @@
 ++++++
 or Dreams, if you prefer
 
+
 A Slimmer Python
 ++++++++++++++++
 People who write code for handhelds and other embedded devices often
@@ -115,10 +124,10 @@
 Reference Language, written in Python itself to stand as the model of
 what is compliant Python.  A PyPy Object Space will provide this.
 Moreover, people who would like to experiment with a proposed Python
-language change will have an easier task.  New language features, such
-as the *2.3 sets* could have profitted from first being written in
-PyPy so that more people could use, comment, and modify them before
-final approval or rejection.  
+language change will have an easier task.  Proposed new language
+features, could profit from first being written in PyPy so that more
+people could use, comment, and modify them before final approval or
+rejection.
 
 Getting better use of machines with multiple CPUs
 ++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -191,7 +200,7 @@
 middle way, a Pythonic way between purity and practicality, theory and
 practice.
 
-PyPy may be able to help.  The separation should make leaving concepts
+PyPy may be able to help.  The separation should make learning concepts
 easier, and the ability to create one's own Object Spaces provides a
 useful way to compare and contrast different techniques.  Finally, we
 could reasonably ask our students to **implement** interesting
@@ -210,9 +219,22 @@
 Object Spaces could provide a better fit between the the abstract
 concepts we wish to teach and the code written to implement just that.
 
+Runtime Adaptation of C-Libraries and System-Calls
+++++++++++++++++++++++++++++++++++++++++++++++++++
+Python is already widely used for integrating and driving C-libraries
+(for numerical compuatation, 3D-modeling etc.).  We dream
+of introducing runtime mechanisms that allow PyPy to directly setup and
+execute "native" calls on a machine.  For this to work we need
+"trampolin" (assembler-) functions that build a C-like stackframe
+and trigger a call directly into e.g. the linux kernel or 
+any C-library without having to use a C-compiler.  This technique
+would clearly be of great value to embedded devices but also
+to regular python applications that could more easily use C-libraries
+once they obtain a pythonic description of the library (possibly
+generated from ``.h`` files).
+
 A Smarter, more Dynamic Interpreter
 +++++++++++++++++++++++++++++++++++ 
-
 A Virtual Machine written in Python, should be easier to maintain and
 optimise. By recording statistics and analysing the bytecodes that are
 running through the machine, it is possible to find a shorter, and
@@ -230,7 +252,8 @@
 to make it faster.  We think we can produce a Just-In-Time compiler which
 is faster than C Python without destroying the clarity in our architecture.
 Indeed, the ability to run different object spaces at the same time, in the
-same interpreter will be most useful in this application.
+same interpreter will be most useful in this application.  Psyco already
+uses similar techniques to great effect.
 
 Speaking of Running different Object Spaces at the Same Time
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -352,7 +375,7 @@
         (23, 'Fram', 2975, 'Potatoes', '3.5 kg @ 8.50SEK'),
         (23, 'Fram', 1421, 'Peas', 'Thursday dinner'),]
 
- print (reduce(lambda x, y: x+y, [t[2] for t in slips], 0))/900 [#]_
+ print (reduce(lambda x, y: x+y, [t[2] for t in slips], 0))/900
 
 Pypy said: 603 SEK, or appoximately 50 USD.   Don't believe people who
 tell you that Sprints are too expensive to hold. 
@@ -362,54 +385,59 @@
 Our third Sprint was held at Louvain-la-Neuve, Belgium (near
 Brussels), June 21 - 24.  Great progress was made with the The
 Annotation Object Space, and began abstract, symbolic interpretation.
+(We also spent a lot of time firming up the Standard Object Space, and
+trying to write documentation).
 
-Current plans are to get the Annotation Object Space to emit Pyrex.
+In the two object spaces so far, application-level objects are
+represented in the interpreter as objects that represent a value.
+This is so obvious as to not need pointing out, except for the fact
+that the Annotation space does something completely different.
+
+Here the interpreter-level object corresponding to a application-level
+variable does not describe the value of the variable, but rather the
+state of knowledge about the contents of the variable.
+For example, after the code::
+
+ x = 1
+ y = 2
+ z = x + y
+
+we know exactly what *x*, *y* and *z* contain: the integers *1*, *2* and *3*
+respectively, and this is how the annotation object space represents
+them: there is a class W_Constant that represents totally known values.
+
+However in::
+
+  def f(x, y):
+      z = x + y
+      
+  f(1, 2)
+  f(2, 3)
+
+we know less.  We know that x and y only contain integers, but their
+values are no longer entirely fixed.  In this case, the annotation
+object space could chose to represent the variable in the body of f
+as *either* the constant *1* or the constant *2*, but at present it punts
+and simply represents it as an instance of W_Integer.
+
+The eventual hope is to run all of the code that implements PyPy's
+interpreter and the standard object space with the annotation object
+space and gain sufficient knowledge of the values involved to generate
+efficent code (in C, Pyrex_, O'Caml, Java or whatever) to do the same
+job.
+
+If you're wondering how we expect to get a speed up of 20000 times by
+this translation when a speed up of 100 or so times is all that
+usually obtained by rewriting in C, you have to understand that the
+main reason for the standard object space's current slowness is the
+computation of which code to execute each time a multimethod is
+called.  The knowledge gathered by the Annontation Object Space should
+be sufficient to remove or at lesat substantially reduce this computation 
+for most of the call sites.
 
-Multimethods
-************
-Interpreter-level classes correspond to implementations of
-application-level types.  The hierarchy among the classes used for the
-implementations is convenient for implementation purposes. It is not
-related to any application-level type hierarchy.
+Current plans are to get the Annotation Object Space to emit Pyrex_.
 
-Dispatch
-++++++++
-Multimethods dispatch by looking in a set of registered
-functions. Each registered function has a signature, which defines
-which object implementation classes are accepted at the corresponding
-argument position.
-
-The name 'W_ANY' is a synonym for 'W_Object' (currently, possibly
-'object' later). As it accepts anything, it is the only way to
-guarantee that the registered function will be called with exactly the
-same object as was passed originally. ATTENTION: in all other cases
-the argument received by the function may have been converted in some
-way. It must thus not be considered to be 'id'entical to the original
-argument. For example it should not be stored in a data structure, nor
-be queried for type, nor be used for another multimethod dispatch --
-the only thing you should do is read and write its internal data.
-
-For example, 'getattr(obj, attr)' is implemented with a W_StringObject
-second argument when all it needs is just the name of the attr, and
-with a W_ANY when the 'attr' object could be used as a key in
-obj.__dict__.
-
-Delegation
-++++++++++
-
-Delegation is a transparent convertion mechanism between object
-implementations. The convertion can give a result of a different type
-(e.g. int -> float) or of the same type (e.g. W_VeryLongString ->
-str). There is a global table of delegators. We should not rely on the
-delegators to be tried in any particlar order, or at all (e.g. the int
--> float delegator could be ignored when we know that no registered
-function will accept a float anyway).
-
-Delegation is also used to emulate inheritance between built-in types
-(e.g. bool -> int). This is done by delegation because there is no
-reason that a particular implementation of a sub-type can be trivially
-typecast to some other particular implementation of the parent type;
-the process might require some work.
+.. _Pyrex: http://www.cosc.canterbury.ac.nz/~greg/python/Pyrex/
 
 Types
 +++++
@@ -428,6 +456,16 @@
 implement special methods like __int__() by calling them within a
 W_UserObject -> int delegator.
 
+Multimethods
+++++++++++++
+Interpreter-level classes correspond to implementations of
+application-level types.  The hierarchy among the classes used for the
+implementations is convenient for implementation purposes. It is not
+related to any application-level type hierarchy.  Multimethods
+dispatch by looking in a set of registered functions. Each registered
+function has a signature, which defines which object implementation
+classes are accepted at the corresponding argument position.
+
 Specifics of multimethods
 +++++++++++++++++++++++++
 Multimethods dispatch more-specific-first, left-to-right (i.e. if
@@ -458,27 +496,15 @@
 potentially be tried, and recursively on each other's results to do
 chaining.
 
-A priority ordering between delegators is used. See objspace.PRIORITY_*.
-
-Translation
-+++++++++++
-The code in multimethod.py is not supposed to be read by the
-translator-to-C. Special optimized code will be generated instead
-(typically some kind of precomputed dispatch tables).
-
-Delegation is special-cased too. Most delegators will be found to
-return an object of a statically known class, which means that most of
-the chaining and loop detection can be done in advance.
-
 Multimethod slicing
 +++++++++++++++++++
 Multimethods are visible to user code as (bound or unbound) methods
 defined for the corresponding types. (At some point built-in functions
-like len() and the operator.xxx() should really directly map to the
+like *len()* and the *operator.xxx()* should really directly map to the
 multimethods themselves, too.)
 
-To build a method from a multimethod (e.g. as in 'l.append' or
-'int.__add__'), the result is actually a "slice" of the whole
+To build a method from a multimethod (e.g. as in *l.append* or
+*int.__add__*), the result is actually a "slice" of the whole
 multimethod, i.e. a sub-multimethod in which the registration table
 has been trimmed down. (Delegation mechanisms are not restricted for
 sliced multimethods.)
@@ -494,11 +520,24 @@
 e.g. for __radd__().
 
 Conclusions
-===========
-<Write me please>
++++++++++++
+It is a little early for conclusions, but our architecture seems to
+be working so far.  Sprints are a lot of fun, and a great way to write
+code, and meet interesting people.  
+
+Thank you
++++++++++
+The members of the PyPy team are distinctly grateful to RyanAir_, without
+which holding Sprints would be prohibitively expensive, and the
+Subversion_ development team, without whom restructuring the entire universe
+whenever we feel like it would have been close to impossible.
+
+.. _RyanAir: http://www.ryanair.com/
+.. _Subversion: http://subversion.tigris.org/
+
 
 .. [#] The PyPy homespage: http://www.codespeak.net/pypy/
-.. [#] See for instance, *lunacy* http://www.nightmare.com/~rushing/lunacy/
+.. [#] See for instance, Scheme48's PreScheme
 .. [#] The Squeak homespage: http://www.squeak.org/
 .. [#] See *Back to the Future The Story of Squeak, A Practical 
        Smalltalk Written in Itself* ftp://st.cs.uiuc.edu/Smalltalk/Squeak/docs/OOPSLA.Squeak.html
@@ -596,8 +635,4 @@
        ]
 
      print [t[2] for t in slips]
-     print (reduce(lambda x, y: x+y, [t[2] for t in slips], 0))/900
-
-.. [#] and the reason I used reduce instead of just a list comprehension
-       is that I had just finished writing unit tests for reduce -- Laura
-
+     print (reduce(lambda x, y: x+y, [t[2] for t in slips], 0))/900
\ No newline at end of file


More information about the Pypy-commit mailing list