Skip to content

normalized input types handling for issue 86 #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

christakahashi
Copy link
Contributor

changes

  • reworked _bytearray to handle input types more uniformly, and added some value checking. _bytearray still defaults to a python bytearray for c_exp<=8. But it now chooses the smallest possible array.array type. This improves performance a little and halves the memory use for the array in cases where 8<e_exp<=16.
  • Also removed the global definition of _bytearray and initialization of globals before the call to init_tables(). The former was only needed for find_prime_polys() when python 2.5 and earlier were used, which are not supported versions of python. (Note: global _bytearray is still needed, its just not initialized until init_tables() is called.)
  • rs_encode_message now only accepts array-like objects of integral types. Its impossible to know the user's intent when given a string.
  • Added a byte packing mode for RSCodec.encode() when pack=True, c_exp=16, and data is given as bytes, or a string with encoding the encoder will pack two bytes per codeword. Note odd numbers of bytes or strings that encode into an odd number of bytes cannot be packed as there is no way to pad the message out and then remove the padding without either making assumptions about the input data or including additional metadata which is not possible within a RS codeword.
  • If given an encoding, RSCodec.decode() will attempt to decode the given bytes back into a string.
  • Added tests for string modes

@lrq3000
Copy link
Collaborator

lrq3000 commented May 12, 2025 via email

fixed handling the case of an empty list.
@christakahashi
Copy link
Contributor Author

I found a small bug in the new _bytearray that I've corrected in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants