Thanks for the info!
Hi Andrew,
On Mon, Mar 28, 2011 at 7:21 PM, Andrew Brown <brownan@gmail.com> wrote:
> When the optimizer encounters a "pure" function, it must compare the objects
> "promote - promote the argument from a variable into a constant". Could thisOne point of view on 'promote' is to mean "this variable was red, but
> be an appropriate alternate to the @purefunction solution? Or, I'm guessing,
> does it just mean the name bracket_map won't change bindings, but does not
> impose a restriction on mutating the dictionary?
now turn it green (i.e. make it constant)". It has no effect on a
variable that is already green (= a constant).
We have no support for considering that a dict is immutable, so it
needs to be done with @purefunction. But to be effective,
@purefunction must receive constant arguments; so in one or two places
in the source code of PyPy you will find a construction like:
x = hint(x, promote=True) # turn x into a constant
some_pure_function(x) # call this pure function on x
Indeed, Carl Friedrich's blog series explains it nicely, but it should
also mention that when the hints described in the blog are applied not
to integer but to pointers, they apply only to the pointers
themselves, not on the fields of the objects they point to.
A bientôt,
Armin.