Issue #1 new

_dictinfo.py for python 3.3

Anonymous created an issue

python 3.3 has 3 structs that define a dictionary object. I am trying to use your code as a guide plus use the cpython source code to modify _dictinfo.py.

The link to my code is here.

Please see lines 98 - 107. I cannot get line 103 to work. Somehow the dictionary does not have the correct underlying structure.

Also: line 45 of my code: 'dk_entries', POINTER(PyDictKeyEntry))

The Cpython struct PyDictKeysObject has the field dk_entries[1], of type PyDictKeyEntry. Is my class PyDictKeysObject defined incorrectly?

After learning about hash tables in an algorithms class, I wanted to explore the collision algorithm of python dictionaries and compare it to a hash table I wrote that uses double hash linear probe open addressing. I plotted the cumulative cost of inserting the words of a Tale of Two Cities into my hash table (written in python). The next step is to plot the same data for a python dictionary.

Then I found your PyCon2010 talk. But now I'm stuck.

Thanks so much! Leslie Klein lesliebklein@gmail.com

Comments (3)

  1. Leslie Klein

    It took a long time to get the translation from C code to python classes. But now my code linked to above works and passes the same tests that Brandon Rhodes provided for his code.

    So now we have a _dictinfo.py for python 3.3 dictionaries. (My code only deals with dictionaries of combined tables.

  2. Brandon Rhodes repo owner

    Thank you for working out how to do this, when I lacked the cycles to jump in yet and help! Would you be interested in submitting a pull request with your code in it, so that you can be an official contributor? I just moved the project to GitHub so that you could make a pull request with your GitHub account if you'd like:

    https://github.com/brandon-rhodes/pycon2010-mighty-dictionary

    If you'd rather not, just let me know, and I'll pull over your code for Python 3 myself. Thanks, either way!

  3. Leslie Klein

    Hi Brandon,

    I just sent you a pull request on github. I forked your repo, cloned it, created a branch called python33, committed my dictinfo33.py to the branch, and pushed to the branch on the fork. I then sent a pull request. I'm telling you this because this is my first time doing it. I believe I got it right.

    Leslie

    -

  4. Log in to comment