I would like to convert a bytearray with ASCII hexadecimal encoded into straight bytes
“ hex_data = b’010203040a0b0fff’
data = bytearray.fromhex(hex_data)``
But this does not work because the fromhex method expect a string a not a bytearray.
I can add an extra step like:
data = bytearray.fromhex(hex_data.decode())
This shall work, but this is adding an extra processing and one more object to be processed by the GC.
The final objective is to also reverse the bytearray so to create an array and reverse it.
Currently I am using a pure Python programming algorithm that works very well
That is executed several 100th times per seconds and start to consume some significant CPU time.
This shall work with Python 3.7