Dag Sverre Seljebotn added the comment:
It is perfectly possible for an object to export memory in a read-only way that
may still change. Another object may have a writeable view:
x = obj.readonly_view
y = obj.writable_view
obj.move_to_next_image() # changes memory under x, y
So, hashing using tobytes() doesn't make any sense at all to me. A memoryview
!= its contents.
You could compare memoryviews simply by comparing the Py_buffer structure, but
that's going to be confusing for a lot of users. I would really prefer
unhashable (+ if needed a method for comparing contents).
(FWIW, not sure how relevant this is; in NumPy, == does
In [1]: np.array([1,2,3]) == np.array([1,3,3])
Out[1]: array([ True, False, True], dtype=bool)
Cython will follow this behaviour for its "typed memory views", which is
Cython's builting mechanism for PEP 3118 which is not quite the same as CPython
"memoryview". But I understand that following this behaviour is probably out of
the question for CPython.)
--
nosy: +Dag.Sverre.Seljebotn
___
Python tracker
<http://bugs.python.org/issue15814>
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com