Importing your module should not have this side effect, changing the behavior of a core python module.
Note that this can lead to an unexpected exception this way:
# start with fresh kernel
import yaml
import vaex
obj = yaml.safe_load( '''{ 'a' : 1, 'b' : 2 }''' ) # returns an OrderedDict
# the output from safe_load is safe, right?
obj_str = yaml.dump(obj)
print(obj_str) # not safe - specifies a OrderedDict class to instantiate, which is what safe_load doesn't allow.
yaml.safe_load(obj_str) # exception - yaml wasn't safe.
# you have to call yaml.safe_dump to dump the OrderedDict back to a normal dict structure
# but safe_load shouldn't produce "unsafe" objects by default.
Description
but
Importing your module should not have this side effect, changing the behavior of a core python module.
Note that this can lead to an unexpected exception this way:
The StackOverflow discussion you linked to from your code warns against this global side effect and has 2 or 3 alternatives. https://stackoverflow.com/questions/5121931/in-python-how-can-you-load-yaml-mappings-as-ordereddicts