makinacorpus / easydict

Access dict values as attributes (works recursively)
GNU Lesser General Public License v3.0
294 stars 47 forks source link

OrderedDict in EasyDict #50

Closed turtoes closed 3 months ago

turtoes commented 4 months ago

I wonder if there is a way to prevent OrderedDict being converted to Easydict object when I assign the OrderedDict into an EasyDict.

For example:

my_easy_dict = EasyDict()

mdl = torch.load("abc.pth",map_location = "cuda:0") # mdl is an OrderedDict

my_easy_dict.mdl = mdl # this case, my_easy_dict["mdl"] is an easydict not OrderedDict.

I wonder if this assignment can stay OrderedDict instead of being converted into EasyDict/

Many Thanks!

leplatrem commented 4 months ago

This would require some code change here:

https://github.com/makinacorpus/easydict/blob/6df258e9bbeb2414bcb747b1691a6fbf5dfb7769/easydict/__init__.py#L151-L152

turtoes commented 3 months ago

This would require some code change here:

https://github.com/makinacorpus/easydict/blob/6df258e9bbeb2414bcb747b1691a6fbf5dfb7769/easydict/__init__.py#L151-L152

I fould that would be the only way to change the logic here. I just pull the entire code to the project to import and change the type filtering for this line. Thanks for the reply