Python Forum
How can I make this function faster? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How can I make this function faster? (/thread-11227.html)

Pages: 1 2


RE: How can I make this function faster? - ichabod801 - Jun-29-2018

I can't think of an efficient way to handle that. You could do:

container = document
sub_keys = key.split('.')
for sub_key in sub_keys[:-1]:
    container = container[sub_key]
container[sub_keys[-1]] = value
but I can't see that being very efficient.