Nick Coghlan <ncogh...@gmail.com> added the comment:

I think Antoine's right that another venue (such as python-ideas) might be a 
better venue for this discussion, but I'll still try to explain the potential 
analogy I see to bytes.upper()/.lower()/etc: those operations let you treat 
ASCII segments in otherwise binary data as ASCII text, *without* needing to 
convert them to str first. While doing the str conversion is more formally 
correct, being able to stay in the raw binary domain frequently offers 
significant practical benefits by reducing both the runtime performance 
overhead and the amount of code needed.

Offering bitwise operations for bytes segments of equal length (perhaps via 
memoryview, or a memoryview subclass that only supports C-contiguous views) 
*might* turn out to offer a similar benefit when it comes to manipulating 
sections of a data buffer that represent integers (or anything else with a 
well-defined binary representation). With the right buffer exporter, you could 
even use it for direct bit-bashing of memory-mapped registers (which then gets 
quite interesting in the context of MicroPython applications).

----------

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

Reply via email to