normalized input types handling for issue 86 #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
changes
_bytearray
to handle input types more uniformly, and added some value checking._bytearray
still defaults to a pythonbytearray
forc_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 where8<e_exp<=16
._bytearray
and initialization of globals before the call toinit_tables()
. The former was only needed forfind_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 untilinit_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.RSCodec.encode()
whenpack=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.RSCodec.decode()
will attempt to decode the given bytes back into a string.