Because of _conversion_checks the complexity of a single __setattr__ is something like O(number_of_keys key_size). Hence the complexity of merge_update would be O(number_of_keys number_of_keys key_size). This comes as a surprise when you expect the complexity to be O(number_of_keys log(number_of_keys)).
This PR addresses this performance issue by using a dictionary mapping safe keys to old keys.
All the unit tests are passing. I am not familiar enough with Box to know if the use of __setattr__ and __setitem__ might lead to an inconsistent state of the Box, or if the unit tests cover this. Eventually, you might consider refactoring the code a bit (this is better done by the author who knows the code well).
This fixes #129.
Because of
_conversion_checks
the complexity of a single__setattr__
is something like O(number_of_keys key_size). Hence the complexity of merge_update would be O(number_of_keys number_of_keys key_size). This comes as a surprise when you expect the complexity to be O(number_of_keys log(number_of_keys)).This PR addresses this performance issue by using a dictionary mapping safe keys to old keys.
All the unit tests are passing. I am not familiar enough with Box to know if the use of
__setattr__
and__setitem__
might lead to an inconsistent state of the Box, or if the unit tests cover this. Eventually, you might consider refactoring the code a bit (this is better done by the author who knows the code well).