{"action":"created","issue":{"url":"https://api.github.com/repos/godotengine/godot/issues/3697","repository_url":"https://api.github.com/repos/godotengine/godot","labels_url":"https://api.github.com/repos/godotengine/godot/issues/3697/labels{/name}","comments_url":"https://api.github.com/repos/godotengine/godot/issues/3697/comments","events_url":"https://api.github.com/repos/godotengine/godot/issues/3697/events","html_url":"https://github.com/godotengine/godot/issues/3697","id":133356168,"number":3697,"title":"Add deep copy functions to Dictionary and Array","user":{"login":"kirilledelman","id":6539713,"avatar_url":"https://avatars.githubusercontent.com/u/6539713?v=3","gravatar_id":"","url":"https://api.github.com/users/kirilledelman","html_url":"https://github.com/kirilledelman","followers_url":"https://api.github.com/users/kirilledelman/followers","following_url":"https://api.github.com/users/kirilledelman/following{/other_user}","gists_url":"https://api.github.com/users/kirilledelman/gists{/gist_id}","starred_url":"https://api.github.com/users/kirilledelman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kirilledelman/subscriptions","organizations_url":"https://api.github.com/users/kirilledelman/orgs","repos_url":"https://api.github.com/users/kirilledelman/repos","events_url":"https://api.github.com/users/kirilledelman/events{/privacy}","received_events_url":"https://api.github.com/users/kirilledelman/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/godotengine/godot/labels/enhancement","name":"enhancement","color":"44bbff"},{"url":"https://api.github.com/repos/godotengine/godot/labels/topic:gdscript","name":"topic:gdscript","color":"ffdd44"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-12T22:13:07Z","updated_at":"2016-02-15T06:13:45Z","closed_at":null,"body":"Hi,\r\nI found that there's no built-in way to deep-clone Dictionary or an Array.\r\nI use these data structures for in-game templates that get data appended by instances, and I needed to clone them, completely and recursively.\r\n\r\nThe best way to do so right now, without writing an even clumsier / less efficient recursive function is to do it like so:\r\n\r\n`dictionaryDeepCopy = str2var( var2str( originalDictionary ) )`\r\n\r\nPlease add `.copy()` method to both Dictionary and Array classes to make a deep / recursive copy of the object ( all elements / values should be deep-copied recursively as well )"},"comment":{"url":"https://api.github.com/repos/godotengine/godot/issues/comments/184078017","html_url":"https://github.com/godotengine/godot/issues/3697#issuecomment-184078017","issue_url":"https://api.github.com/repos/godotengine/godot/issues/3697","id":184078017,"user":{"login":"nopeson","id":16130334,"avatar_url":"https://avatars.githubusercontent.com/u/16130334?v=3","gravatar_id":"","url":"https://api.github.com/users/nopeson","html_url":"https://github.com/nopeson","followers_url":"https://api.github.com/users/nopeson/followers","following_url":"https://api.github.com/users/nopeson/following{/other_user}","gists_url":"https://api.github.com/users/nopeson/gists{/gist_id}","starred_url":"https://api.github.com/users/nopeson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nopeson/subscriptions","organizations_url":"https://api.github.com/users/nopeson/orgs","repos_url":"https://api.github.com/users/nopeson/repos","events_url":"https://api.github.com/users/nopeson/events{/privacy}","received_events_url":"https://api.github.com/users/nopeson/received_events","type":"User","site_admin":false},"created_at":"2016-02-15T06:13:45Z","updated_at":"2016-02-15T06:13:45Z","body":"Oh yes, missed those functions some times too.\r\nI think a good way according to the former style would be\r\n`var new_array = Array(old_array)`\r\nit's the (one) way, I would handle it in Python too.\r\nOtherwise a `.copy()` method sounds good too."}}