On 16/07/2015 07:37, Ben Finney wrote:
Ethan Furman <et...@stoneleaf.us> writes:

On 07/15/2015 10:53 PM, Ben Finney wrote:
Are those the ‘__contains__’, ‘__getitem__’ methods? What actually
is the API of a mapping type, that would need to be customised for
this application?

The problem is that potential key matches are found by hashes

For the Python ‘dict’ type, yes. I already know that I don't want that
type, I want a custom mapping type which matches keys according to the
algorithm I specify.

So, I'm not asking “how do I make ‘dict’ do this?”. I am instead asking
“how do I implement a custom type which can duck-type for ‘dict’ but
have a different key-lookup implementation?”.


https://docs.python.org/3/reference/datamodel.html?emulating-container-types

<quote>
The collections module provides a MutableMapping abstract base class to help create those methods from a base set of __getitem__(), __setitem__(), __delitem__(), and keys()
</quote>

Hence https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping

Hunting for examples got me to http://code.activestate.com/recipes/578096-a-mutablemapping-that-can-use-unhashable-objects-a/ so fingers crossed, I'm just hoping that we're going in the right direction.

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to