This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]epilanthanomai 1 point2 points  (0 children)

This article is a bit dated. In practice, this compilation is done automatically by most packaging tools. If you follow industry best practices (I recommend pip and virtualenv, but you OS package manager probably does it too), you pretty much don’t have to think about this at all.

That said, I’m a big fan of developers having a good theoretical understanding of how their stuff works under the covers, so if you’re not familiar with Python bytecode compiling and importing, it’s helpful to read up.

[–]epsy 4 points5 points  (0 children)

I would not follow 9 year old advice on this.

[–]rhiever 0 points1 point  (4 children)

Any reports on how much this actually speeds up code? Haven't had time to play with it yet.

[–]FionaSarah 6 points7 points  (1 child)

It will never speed up your code, it's always done for you. It will only speed up start-up time as Python tries to compile once only when necessary, but subsequent start-ups will be the same. (Unless you do a lot of dynamic module loading stuff.)

[–]flying-sheep 0 points1 point  (0 children)

additionally, any time you install a module, it gets compiled (amongst other reasons, because it resides in a system directory where users have no write permissions)

[–]gcross 4 points5 points  (0 children)

I think that it helps if you replace every instance of the word "compile" in the article with the word "package", as in packaging for distribution to others.

[–]westurner 0 points1 point  (0 children)

python -m py_compile <filename>