[pypy-dev] The correct way to incrementally build list in RPython

Armin Rigo arigo at tunes.org
Fri Jun 27 12:37:32 CEST 2014


Hi Yichao,

On 27 June 2014 12:17, Yichao Yu <yyc1992 at gmail.com> wrote:
> I am still creating a tuple out of these 5 numbers/strings since I
> don't want to duplicate the hash functions for all of them. Can the
> compiler deal with this case efficiently?

If by "deal with this case efficiently" you mean, will the compiler
remove the tuple allocation and inline the 5-elements hash, then it
might just be possible depending on a number of details, but I doubt
it.  Better to be explicit.  I had in mind something like:

    my_hash = num1 * 1000003
    my_hash = (my_hash ^ num2) * 1000003
    my_hash = (my_hash ^ compute_hash(string3))
    my_hash = intmask(my_hash)   # at the end


A bientôt,

Armin.


More information about the pypy-dev mailing list