Skip to content

Allow conversion of strings and ints directly into Hash

Latest

Choose a tag to compare

@benhall-7 benhall-7 released this 05 Jan 23:19
· 3 commits to master since this release

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!