David Wilson added the comment:

Stefan, I like your new idea. If there isn't some backwards compatibility 
argument about mmap.mmap being hashable, then it could be considered a bug, and 
fixed in the same hypothetical future release that includes this BytesIO 
change. The only cost now is that to test for hashability, we must hash the 
object, which causes every byte in it to be touched (aka. almost 50% the cost 
of a copy)

If however we can't fix mmap.mmap due to the interface change (I think that's a 
silly idea -- Python has never been about letting the user shoot themselves in 
the foot), then the specialized-for-Bytes approach is almost as good (and 
perhaps even better, since the resulting concept and structure layout is more 
aligned with Serhiy's patch in issue15381).

tl;dr: 

a) mmap.mmap can be fixed - use hashability as strong test for immutability 
(instead of ugly heuristic involving buffer blags)
   - undecided: is calling hash(obj) to check for immutability too costly?

b) mmap.mmap can't be fixed - use the Bytes specialization approach.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22003>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to