Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling it to PYC to reduce loading time. #22534

Closed
joeschmoe40 opened this issue Sep 28, 2019 · 9 comments
Closed

Compiling it to PYC to reduce loading time. #22534

joeschmoe40 opened this issue Sep 28, 2019 · 9 comments
Labels

Comments

@joeschmoe40
Copy link

@joeschmoe40 joeschmoe40 commented Sep 28, 2019

Checklist

  • [ x] I'm asking a question
  • [x ] I've looked through the README and FAQ for similar questions
  • [x ] I've searched the bugtracker for similar questions including closed ones

Question

WRITE QUESTION HERE

(Running under Linux - latest version (2019.09.28))

The version of youtube-dl that I've used for many years now comes as a ZIP file with the first line being "#!/usr/bin/env python". It works fine, but takes a while to load. I am looking to speed that up. I have a cron job that runs every morning (early) and does "youtube-dl -U". I mention this just to be clear that that's how I keep it up-to-date.

Here's what I have done - and it seems to work, but I have not tested throughly.

Is this OK? Or is there a better way to get a compiled version?

  1. Make a copy of youtube-dl - remove the first line. Save this as "foo.zip".
  2. unzip foo
  3. python -m compileall ./
  4. zip -q youtube-dl .pyc youtube-dl/.pyc youtube_dl//.pyc
  5. { echo '#!/usr/bin/python';cat youtube-dl.zip; } > youtube-dl.py
  6. chmod +x youtube-dl.py && time ./youtube-dl.py

This all seems to work, and the resulting executable, while bigger (about 2.4M vs. about 1.7M) than the original, loads and runs faster (about 1.2 seconds vs. 5.4 seconds).

@joeschmoe40
Copy link
Author

@joeschmoe40 joeschmoe40 commented Sep 28, 2019

For some reason, it seems to have removed the asterisks in the "zip" command line.

It should read {star}.pyc in each of the three places.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Sep 28, 2019

Use lazy extractors.

@dstftw dstftw closed this Sep 28, 2019
@joeschmoe40
Copy link
Author

@joeschmoe40 joeschmoe40 commented Sep 28, 2019

What does "use lazy extractors" mean?

(I have no idea what you mean by that or why you closed the thread)

@joeschmoe40
Copy link
Author

@joeschmoe40 joeschmoe40 commented Sep 29, 2019

Also, how do I "un-close" the thread?

@joeschmoe40
Copy link
Author

@joeschmoe40 joeschmoe40 commented Sep 30, 2019

Hmmm.

No response. Maybe moderators screwed up???

Anyway, how do I un-close this?

@Hrxn
Copy link

@Hrxn Hrxn commented Sep 30, 2019

You can't.

@joeschmoe40
Copy link
Author

@joeschmoe40 joeschmoe40 commented Sep 30, 2019

OK. So I need to start a new thread.

@Hrxn
Copy link

@Hrxn Hrxn commented Sep 30, 2019

Probably not.

There is some code for lazy loading in youtube-dl/devscripts...

But this lead nowhere ahead so far.
To be honest, the priority is not really there. That bit of loading time does not matter, download time is always the deciding factor.

@joeschmoe40
Copy link
Author

@joeschmoe40 joeschmoe40 commented Oct 1, 2019

Generally, that would be true (that load time is small compared to download time).

But my use of youtube-dl is primarily not for downloading, but only for "translating" "web-page" URL to "download" URL. Then I play the video via a player that can play URLs directly without downloading them.

My general feeling is that the process takes about 10-15 seconds, and I think about 2/3 of that is the loading time. If I can get the loading time down from about 10 seconds to 5 seconds, that's a significant improvement.

Stuff I've read on another support board indicates that if you install youtube-dl via "pip" instead of via direct download (and subsequent use of "-U"), you will get a pre-compiled version and that that version loads faster.

However, since I don't understand what "pip" is or why it is worth learning about it, I prefer to stick with the method(s) I'm familiar with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.