[Python-Dev] Python Call Mechanism
01 Nov 2000 18:13:07 +0000
Jeremy Hylton <email@example.com> writes:
> >>>>> "MAL" == M -A Lemburg <firstname.lastname@example.org> writes:
> MAL> Jeremy Hylton wrote:
> >> Update of /cvsroot/python/python/dist/src/Python In directory
> >> slayer.i.sourceforge.net:/tmp/cvs-serv32349/Python
> >> Modified Files: ceval.c ... N.B. The CALL_FUNCTION
> >> implementation is getting really hairy; should review it to see
> >> if it can be simplified.
> MAL> How about a complete redesign of the whole call mechanism ?!
> I'd be interested in looking at it.
Random idea that occurred while answering a post on comp.lang.python:
How about dumping the CALL_FUNCTION* opcodes, and replacing them with
two non-argumented opcodes, called for the sake of argument NCALL_FUNC
NCALL_FUNC would pop a function object and a tuple off the stack and
apply the function to the tuple.
NCALL_FUNC_KW would do the same, then pop a dictionary and then do
the moral equivalent of f(*args,**kw).
As a preliminary it would be sensible to rework BUILD_MAP so that it
built dictionaries off the stack (a bit like BUILD_LIST, and like
CALL_FUNCTION now does with keyword arguments...) (and extend the
compiler to use this for literal dictionaries).
This would add an opcode or so per function call, but would probably
make life much simpler.
No time for implementation tonight, but could probably knock something
up tomorrow (depending how hard it turns out to be).
Thoughts? Is that like what you did, Marc?
Those who have deviant punctuation desires should take care of their
own perverted needs. -- Erik Naggum, comp.lang.lisp