[pypy-dev] die cpythonobject, die!
mwh at python.net
Wed Jul 14 15:44:18 CEST 2004
Cc:ing pypy-dev back in, assuming it's omission was just a
slip... (also why I'm not snipping the quoted material).
Richard Emslie <rxe at ukshells.co.uk> writes:
> Hi Michael,
> On Wed, 14 Jul 2004, Michael Hudson wrote:
>> This surprisingly brief patch removes all uses of W_CPythonObject
>> (though not all uses of W_BuiltinFunctionObject), by using the
>> 'automatically faking non re-implementations' technique I've talked
>> about before.
> Second guessing here, but I reckon that within
> there is a comment "special-case Functions to avoid infinite
> recursion" that is the start of the problems.
> The above line instead of -
> if type(descr) is Function:
> could be replace with (I think 80%)
> if hasattr(descr, "call_args"):
> and then have a special case for faking SlotWrapperType s called
> fake_function() which looks something like
> def fake_function(space, cpy_func):
> W_FakeFunction = fake_type(space, cpy_func)
> W_FakeFunction.__name__ = 'W_FakeFunction(%s)'%(cpy_func.__name__)
> def call_args(self, args):
> unwrappedargs = [space.unwrap(w_arg) for w_arg in args.args_w]
> unwrappedkwds = dict([(key, space.unwrap(w_value))
> for key, w_value in args.kwds_w.items()])
> except UnwrapError, e:
> raise UnwrapError('calling %s: %s' % (cpy_func, e))
> assert callable(self.val), self.val
> result = apply(self.val, unwrappedargs, unwrappedkwds)
> return space.wrap(result)
> setattr(W_FakeFunction, "call_args", call_args)
> return W_FakeFunction
> Don't know - it's very much guess work. Hope that helps - it works
> for me and might at least give you some idea how to solve.
Well, I think that could work but I'd prefer a solution with less
How does CPython avoid the same problem?
-Dr. Olin Shivers,
Ph.D., Cranberry-Melon School of Cucumber Science
-- seen in comp.lang.scheme
More information about the Pypy-dev