#15367: Empty lists while creating parents
-------------------------------------+-------------------------------------
       Reporter:  roed               |        Owner:
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-5.13
      Component:  coercion           |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Nils Bruin         |    Reviewers:  Simon King
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  u/nbruin/ticket/15367              |  b95fa73c3fca342851dde858028a12629c6147ee
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by SimonKing):

 Replying to [comment:33 nbruin]:
 > Replying to [comment:32 SimonKing]:
 > > Can you elaborate: What is `PyCapsule`? I've never heard of it.
 >
 > It's a python object wrapping a `void *`:
 http://docs.python.org/2/c-api/capsule.html , so it does exactly what we
 need.

 Thank you for the pointer!

 > > Concerning the hash function: Didn't we have the current hash function
 `<size_t>key1 + 13*(<size_t>key2) ^ 503*(<size_t>key3)` in the original
 implementation? If I recall correctly, I chose it because it was
 recommended as a good hash function for tuples.
 >
 > It is indeed a good hash function, particularly for moduli that are a
 power of 2. Where did you get it from? or was it already in the code?

 It has been in the code (as I have just checked by looking at the patch
 from #715).

 When we tried to create a generalisation of `TripleDict` towards a
 dictionary with fixed key length at #12313, I did some google search
 concerning hash functions for tuples. I don't recall the web page, but it
 resulted in this code, see attachment "idkey_dict" at #12313:
 {{{
 cdef list find_bucket(self, tuple keytuple):
     # Determine the appropriate bucket
     cdef size_t h = 0x345678
     cdef size_t i
     for i from 0<=i<self._keylen:
         h *= 1000003
         h ^= <size_t>PyTuple_GET_ITEM(keytuple,i)
     cdef list all_buckets = self.buckets
     return <object>PyList_GET_ITEM(all_buckets, h %
 PyList_GET_SIZE(all_buckets))
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/15367#comment:36>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to