Releases: benhall-7/pyprc
Releases · benhall-7/pyprc
Allow conversion of strings and ints directly into Hash
With this release, the user can assign strings and ints anywhere where a Hash class is expected and python will convert it seamlessly. Consider these two examples:
Ex 1:
# old
p_struct = param.struct([(hash("dummy"), param.u8(1))])
p_struct[hash("dummy")].value = 2
# new
p_struct = param.struct([("dummy", param.u8(1))])
p_struct["dummy"].value = 2
Ex 2:
# old
p_hash = param.hash(hash("dummy"))
p_hash.value = hash("test")
# new
p_hash = param.hash("dummy")
p_hash.value = "test"
All the previous rules about hash behavior, label lookups, should work exactly the same. Not only will it accept strings, but it will also accept raw Ints and also other Hashes. If you notice any bugs, please let me know!
Support modern Python versions (3.7+)
This release supports arbitrary Python versions as low as Python 3.7. It involved some structural changes to the code, but it should not have affected the behavior of the code. Please let me know if you have any bugs!
Updated hash methods and support python version 3.10
- Python versions available have been shifted from [3.6 to 3.9] to [3.7 to 3.10] to support the latest version.
- The
hash
class now relies on the loaded label map to determine how to convert a string into a hash. If a label isn't found, it falls back to the regular algorithm. - You can also use the
hash.set_strict(true)
method to change the fallback behavior, and throw an error if the label is not found. This might help a user to catch typos in label names. - With the
hash.algo("my_string")
method, you can use the hash40 algorithm directly and skip label lookups. You probably will not need to use this unless you are using the strict flag.
0.3.0
- Before, the mutate method would simply redefine the pointer associated with a variable, but not change underlying values of the original pointer. Clearly I didn’t test this well enough because I expected it to rewrite params entirely.
- The ‘mutate’ method has been removed and replaced with several new methods, one for each possible param type: ‘set_bool’, ‘set_i8’, etc. This functions similarly to the param constructors, but it operates on existing param objects. Just provide a value to set the param to. Since most params are alterable by value, this allows you to also change the type of a param, or to change list/struct params after altering them via separate data structures
0.2.0
‘hash’ class changes:
- hash.value now returns the integer representation always
- str(hash) now returns the string representation without any prefix
- before: ‘hash (“param_name”)’
- after: “param_name”
- repr(hash) still returns the former representation
‘param’ changes:
- You can now retrieve length of param structs and lists directly with len(param)
- You can now mutate a param‘s identity with the param.mutate method. Whereas in order to do this previously, you would need to access the parent and reassign this param to a new one, you can now do it with a direct reference. This allows you to convert list or struct params to an intermediate form (lists or dicts), edit them, then modify the base param without going through its parent