[issue15814] memoryview: equality-hash invariant

Dag Sverre Seljebotn report at bugs.python.org
Fri Aug 31 05:47:33 CEST 2012


Dag Sverre Seljebotn added the comment:

OK, I can understand the desire to make memoryviews be bytes-like objects (though to my mind, bytes is "frozen" in a very different way...)

If so, and it is deemed worth it, my suggestion is to add a new PyBUF_CONST flag to the buffer acquisition in that case (which can not be used together with PyBUF_WRITABLE). Given that flag, the exporter guarantees that the contents does not change (or fails to give away a buffer).

Perhaps it could be possible for hash() to try to re-acquire a const buffer, so that some buffers are hashable (by contents) and others not.

(I really think relying on buffers that are not writeable to be constant is dangerous. A readonly memoryview could for instance point straight to the live output of a webcam.)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15814>
_______________________________________


More information about the Python-bugs-list mailing list