A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2016-January/142664.html below:

[Python-Dev] bitwise operations for bytes and bytearray

[Python-Dev] bitwise operations for bytes and bytearray [Python-Dev] bitwise operations for bytes and bytearrayBlake Griffith blake.a.griffith at gmail.com
Thu Jan 7 17:26:23 EST 2016
Hi!

I'm interested in adding the functionality to do something like:

>>>  b'a' ^ b'b'
b'\x03'


Instead of the good ol' TypeError.

I think both bytes and bytearray should support all the bitwise operations.

I've never hacked on cpython before. I'm starting by just trying to add xor
to bytearray. I have a ByteArray_Xor function that I think should do this
here
https://github.com/cowlicks/cpython/commit/d6dddb11cdb33032b39dcb9dfdaa7b10d4377b5f

But I'm not sure how to hook this in to the rest of cypython. I tried
adding it where bytearray_as_sequence is declared in this bytearrayobject.c
file. But that gave me compiler warnings and broke things.

So now that I have this ByteArray_Xor function, how do I make it be
bytearray.__xor___?

Thanks!

Blake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20160107/86243ac9/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4