Because PyRegisterMachine2 is GPL’ed everybody is able to modify the code and redistribute the (modified) code, according to the GNU GPL v3.
If you want to share your changes on the main branch, just send a pull request (via GitHub).
A collection of conversion functions/generators.
py_register_machine2.engine_tools.conversions.
bytes_to_int
(bytes_, width=None)[source]¶Converts the bytes
object bytes_
to an int
.
If width
is none, width = len(byte_) * 8
is choosen.
See also: int_to_bytes
Example
>>> from py_register_machine2.engine_tools.conversions import *
>>> i = 4012
>>> int_to_bytes(i)
b'¬'
>>> bytes_to_int(int_to_bytes(i)) == i
True
py_register_machine2.engine_tools.conversions.
chunks
(iterable, size=8)[source]¶from Stack Overflow
py_register_machine2.engine_tools.conversions.
int_to_bytes
(int_, width=None)[source]¶Converts the int
int_
to a bytes
object.
len(result) == width
.
If width
is None, a number of bytes that is able to hold the
number is choosen, depending on int_.bit_length()
.
See also: bytes_to_int
Operations used by the engine.
py_register_machine2.engine_tools.operations.
bitsetxor
(b1, b2)[source]¶If b1 and b2 would be int
s this would be b1 ^ b2
:
>>> from py_register_machine2.engine_tools.operations import bitsetxor
>>> b1 = [1, 1, 1, 1]
>>> b2 = [1, 1, 0, 1]
>>> bitsetxor(b1, b2)
[0, 0, 1, 0]
>>> bin(0b1111 ^ 0b1101)
'0b10'