Hi there,

   I've question concerning handling of hash value vs portability. Is sage
developer guide manual one can read:

    Here is the definition of __hash__ from the Python reference manual.

        Called for the key object for dictionary operations, and by the
        built-in function hash(). Should return a 32-bit integer usable as a
        hash value for dictionary operations.

However with ipython (on a 64 bits machine):

    In [1]: hash(None)
    Out[1]: 140504985179472

which definitely does looks like a 32 bit value. Moreover, it seem that in
python ref man, [2], the sentence about 32-bits has been removed. So I have
two questions:

1. I think we should update the devguide, or is there something I don't get ?

2. I'm writing a Cython class which caches the hash value. Which type should I
   use for the attribute ? int doesn't work since when trying to store the
   hash of None in an int I get

      OverflowError: value too large to convert to int

   Is long ok and portable (it is was is used in a few place in sage) ? Should
   we write it in the doc ?

Cheers,

Florent

[1] 
http://www.sagemath.org/doc/developer/coding_in_python.html#the-hash-special-method
[2] http://docs.python.org/reference/datamodel.html#object.__hash__

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to