[issue8699] Equality and hashing for functools.partial

2010-09-10 Thread Daniel Urban

Daniel Urban  added the comment:

Is there anybody, who is interested in this?
There are some substantial problems with it (hashing a dict), so I suggest that 
this should be closed, unless somebody is interested.

--
status: open -> pending

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8699] Equality and hashing for functools.partial

2010-09-10 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Thanks for the interesting thread.
I do agree with your suggestion to close this one though.

--
nosy: +rhettinger
resolution:  -> rejected
status: pending -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8699] Equality and hashing for functools.partial

2010-05-12 Thread Daniel Urban

New submission from Daniel Urban :

On python-dev came up an idea [1] to support equality (== and !=) and hashing 
by functools.partial instances.  Van Lindberg provided an implementation 
written in Python [2].  I've made a very similar implementation in C (in 
Modules/_functoolsmodule.c).  The Python equivalent of my code is in 
Lib/test/test_functools.py as the PythonPartialCls class.  The hashing differs 
a little from Van Lindberg's implementation: I'm computing the "normal form" of 
the dict as the sorted list of its items (not as the sorted list of the keys 
followed by the items).  (It was easier to implement this way.)

I haven't made a lot of Python programming in C, so I'm not sure I made 
everything in the right way (especially the reference counting).  Anyway, I'm 
attaching my patch.  I'd appreciate every suggestion, and will try to correct 
my mistakes.
Thanks!

[1] http://mail.python.org/pipermail/python-dev/2010-May/099981.html
[2] http://mail.python.org/pipermail/python-dev/2010-May/06.html

--
components: Extension Modules
files: partial_eq_hash.diff
keywords: patch
messages: 105591
nosy: durban
priority: normal
severity: normal
status: open
title: Equality and hashing for functools.partial
type: feature request
versions: Python 3.2
Added file: http://bugs.python.org/file17311/partial_eq_hash.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8699] Equality and hashing for functools.partial

2010-05-13 Thread Daniel Urban

Daniel Urban  added the comment:

Sorry, I realized I made a stupid mistake.  (I didn't use PyList_Sort to sort 
the list in partial_hash.)
Here is the corrected patch.

--
Added file: http://bugs.python.org/file17315/partial_eq_hash_2.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8699] Equality and hashing for functools.partial

2010-05-13 Thread Daniel Urban

Daniel Urban  added the comment:

On python-dev Yaniv Aknin pointed out that the keywords dictionary of a partial 
object is mutable [1].  This causes problems with hashing and equality.  The 
new patch replaces the keywords dictionary with a read-only proxy of that 
dictionary.  This seems to solve the problem. 

[1] http://mail.python.org/pipermail/python-dev/2010-May/100059.html

--
Added file: http://bugs.python.org/file17318/partial_eq_hash_3.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue8699] Equality and hashing for functools.partial

2010-05-16 Thread Daniel Urban

Daniel Urban  added the comment:

In this new patch, __eq__ compares also the __dict__ of the two partial 
instances.

--
Added file: http://bugs.python.org/file17363/partial_eq_hash_4.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com