[pypy-dev] PyPy newbie question: How to play with types
arigo at tunes.org
Sat Nov 19 19:59:29 CET 2005
On Fri, Nov 18, 2005 at 02:32:28PM +0200, Noam Raphael wrote:
> File "/home/noam/sand/pypy/pypy/objspace/descroperation.py", line 573, in ?
> raise Exception, "missing def for operation%s" % _name
> Exception: missing def for operationfrozen
Indeed, to allow the user to define custom '__freeze__' method there is
a step to take in descroperation.py that I forgot. See for example
'def setitem'. It would go something like:
def freeze(space, w_obj):
w_descr = space.lookup(w_obj, '__freeze__')
if w_descr is None:
# no __freeze__, complain or perform some default behavior
return space.get_and_call_function(w_descr, w_obj)
Adding another optional argument needs to be done with some care,
because most of the places will internally need a non-optional argument.
It's possible in theory to have default arguments on multimethods, but I
suppose that you should just make the user-visible 'freeze()' in the
__builtin__ module accept less arguments and add a default if necessary.
About the py lib: the "Svn-check out" instructions at
should have checked out the 'py' subdirectory as well.
More information about the Pypy-dev