[pypy-dev] Re: Compiler
Armin Rigo
arigo at tunes.org
Mon May 9 16:32:30 CEST 2005
Hi Ludovic,
(Replying here for reference, repeating our IRC conversation)
On Mon, May 09, 2005 at 12:59:01PM +0200, Ludovic Aubry wrote:
> > The difference with the getattr() case is that the operation that
> > replaces it, a getitem on a constant dictionary, has a reasonable
> > C-level equivalent, namely a (precomputed) hash table lookup.
> sure, I discussed that with Hoelger already, thing is the visitor isn't
> used for parsing but only by the EBNFParser which parses the python
> grammar file and turn it into a tree of grammar object
> This should be called only at startup time.
Then there is no need to change this source, indeed.
> I must say I am not sure whether the following call in recparser/__init__.py:
> PYTHON_PARSER = pythonutil.python_grammar()
> really is called at bootstrap time ?
Yes, "bootstrap time" is actually a long time. All .py modules are
imported at bootstrap time. Their 'def' and 'class' statements are all
executed at bootstrap time -- defining new functions and classes is
forbidden in RPython. It means that you can actually put any strange
full Python code in the global "top-level" code of any module. The
above line can go in the globals of the most convenient module, not only
__init__.py.
A bientot,
Armin.
More information about the Pypy-dev
mailing list