[pypy-dev] Re: hints about contributing to builtins

Christian Tismer tismer at tismer.com
Sun Mar 2 00:51:41 CET 2003


Laura Creighton wrote:
> I would like some :-)

Well, it's really hard to give advice. I have my
opinions, which you know are sometimes quite
different from other's, and the list seems to
be quite quiet on the weekend...

There are a couple of open issues when looking
into builtins. One of these is btw., that we didn't
define a module object, yet, which we really need
since builtins is a module.

Then, by looking at some simple function in builtinmodule,
even more questions are raised:

static PyObject *
builtin_isinstance(PyObject *self, PyObject *args)
{
	PyObject *inst;
	PyObject *cls;
	int retval;

	if (!PyArg_ParseTuple(args, "OO:isinstance", &inst, &cls))
		return NULL;

	retval = PyObject_IsInstance(inst, cls);
	if (retval < 0)
		return NULL;
	return PyInt_FromLong(retval);
}

What do we have here?
First of all, there is the Python calling convention,
that every function call has a self argument, may this
be used or not. Builtins doesn't use it at all, so you
always can ignore self.
But then, what about the arg tuple?
I didn't find any definition how this is handled.
Well, let me look into the interpreter, there they
must have some notation of a function call..............
...back from there.

As far as I can see it, we end up being called like this:

     w_result = f.space.call(w_function, w_arguments, w_keywords)
     f.valuestack.push(w_result)

(from opcode.py)
Now let me dive into objectspace :-)

Unfortunately, even the trivial space doesn't run under
PythonWin or Boa constructor, so I can't use the debugger.

Aha, as it looks right now, we do not distinguish different
calling conventions, and we have to deal with something
like

def builtin_isinstance(*args, **kwds):

The problem is then that we don't have PyArg_ParseTuple and
friends, yet, and we have not settled down where
we can find PyObject_IsInstance implemented.

Question: To get things going, should we simply use the
given function interfaces from CPython, and code some
PyArg_ParseTuple away?
Question: Where do we put undefined stuff, when we want
to write a module like builtins?

Sigh...
This seems to be a bit too hard for me, tonight.

Maybe someone on the list has an idea how to bootstrap
all this stuff?

good nite - chris
-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/




More information about the Pypy-dev mailing list