Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[jsinterp] Avoid double key lookup for setting new key
In order to add a new key to both __objects and __functions dicts on jsinterp.py, it is necessary to first verify if a key was present and if not, create the key and assign it to a value. However, this can be done with a single step using dict setdefault method.
- Loading branch information
7c05097
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a huge regression performance wise.
After the commit above doing this:
xxx@xxx:~/youtube-dl# ./youtube-dl http://youtube.com/?v=qim0Fzozd3Qg -f 18 --no-cache-dir -v
Makes the followning ultra slow:
Reverting makes it fast again.
7c05097
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is only equivalent to
if
x
is idempotent. While I think that idempotence may be true here by accident, the commit fails to contain a rationale of why that should be the case.When
x
is idempotent but expensive to compute, the code may slow down. Here, that seems to be the case, judging by @ShaddyShow's post.Therefore, I have reverted this change in 1f749b6 .
7c05097
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the super fast reaction, the revert and the publishing of the new version.
All back to normal :)