[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Changes by Alexander Belopolsky belopol...@users.sourceforge.net: -- status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Issue #9778 makes this out of date. -- assignee: tim_one - belopolsky nosy: -BreamoreBoy resolution: - out of date status: open - pending superseder: - Make hash values the same width as a pointer (or Py_ssize_t) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Mark Lawrence breamore...@yahoo.co.uk added the comment: As this is a small patch about which there is one statement from Martin that says I believe the proposed patch is fine, there is only one query from Antoine, and because the issue discussed refers to problems with 32 and 64 bit sizes, could someone with the relevant knowledge please take a look with a view to moving this forward. -- nosy: +BreamoreBoy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Responding to Antoine question, I don't understand how you would use a union here. Certainly you cannot define Py_dicthashcache_t as a union of long and Py_ssize_t because it will not be able to easily assign long or Py_ssize_t values to it. I don't think ANSI C allows a cast from integer type to a union. I am OK with the patch, but if this goes into 2.7/3.x, I think the same change should be applied to the set type. -- nosy: +belopolsky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: On the second thought, this comment: - /* Cached hash code of me_key. Note that hash codes are C longs. -* We have to use Py_ssize_t instead because dict_popitem() abuses -* me_hash to hold a search finger. -*/ suggests that a union may be appropriate here. I am not sure of the standards standing of anonymous unions, but if we could do union { Py_ssize_t me_finger; long me_hash; }; it would cleanly solve the problem. If anonymous unions are not available, a regular union could also do the trick: union { Py_ssize_t finger; long hash; } me; and use me.finger where me is used as search finger and me.hash where it stores hash. Less clever naming scheme would be welcome, though. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Please ignore my comment about set type. Sets don't have this issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Yet it looks like set has a bigger problem whenever sizeof(Py_ssize_t) sizeof(long). setentry.hash is defined as long, but set_pop() stores a Py_ssize_t index in it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: I am attaching a patch that uses a regular union of long and Py_ssize_t to store cached hash/index value in both set and dict entry. Using an anonymous union would simplify the patch and would reduce the likelihood of breaking extensions that access entry structs. -- Added file: http://bugs.python.org/file18004/issue1646068.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Martin v. Löwis mar...@v.loewis.de added the comment: If this goes in, it can't go into bug fix releases, as it may break the ABI. -- versions: -Python 2.6, Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Mark Dickinson dicki...@gmail.com added the comment: The approach in Alexander's patch looks fine to me. +1 on applying this patch if someone can test it on a platform where sizeof(long) sizeof(Py_ssize_t), and also verify that there are current test failures that are fixed by this patch. (If there are no such tests, we should add some.) I've only tested this on machines with sizeof(long) == sizeof(Py_ssize_t) == 4 and sizeof(long) == sizeof(Py_ssize_t) == 8, which isn't really much of a test at all. ked-tao, if you're still listening: are you in a position to test Alexander's patch on a relevant machine? -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Changes by Terry J. Reedy tjre...@udel.edu: -- versions: +Python 2.7, Python 3.1, Python 3.2 -Python 3.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Changes by Daniel Diniz aja...@gmail.com: -- components: +Build stage: - patch review type: - feature request versions: +Python 2.7, Python 3.1 -Python 2.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Changes by Daniel Diniz aja...@gmail.com: -- keywords: +patch type: feature request - behavior versions: +Python 2.6, Python 3.0 -Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1646068 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1646068] Dict lookups fail if sizeof(Py_ssize_t) sizeof(long)
Antoine Pitrou added the comment: The patch looks fine, but why isn't an union used instead of trying to figure out the longest of both types? -- nosy: +pitrou _ Tracker [EMAIL PROTECTED] http://bugs.python.org/issue1646068 _ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com