News for hackers. Stuff that matters.
Re:Why Python keeps growing, explained by moffkalast on Friday March 03, 2023 @08:08AM (#35009060)
Well at least 10x, sometimes more. Not really surprising when you think about that it's a VM reading and parsing your code as a string at runtime.
Re:Why Python keeps growing, explained by bombolo on Friday March 03, 2023 @08:24AM (#35009241)
> it's a VM reading and parsing your code as a string at runtime.

Commonly it creates the .pyc files, so it doesn't really re-parse your code as a string every time. But it does check the file's dates to make sure that the .pyc file is up to date.

On debian (and I guess most distributions) the .pyc files get created when you install the package, because generally they go in /usr and that's only writeable by root.

It does include the full parser in the runtime, but I'd expect most code to not be re-parsed entirely at every start.

The import thing is really slow anyway. People writing command lines have to defer imports to avoid huge startup times to load libraries that are perhaps needed just by some functions that might not even be used in that particular run.

Re:Why Python keeps growing, explained by moffkalast on Friday March 03, 2023 @08:55AM (#35009663)
Aren't those pyc files still technically just string bytecode, but encoded as hex?
Re:Why Python keeps growing, explained by bombolo on Friday March 03, 2023 @09:24AM (#35009974)
Well bytecode isn't the same as the actual code you write in your editor.
Re:Why Python keeps growing, explained by kaba0 on Friday March 03, 2023 @09:18AM (#35009916)
> re-parse your code as a string every time

That doesn’t really take any significant time though on modern processors.