Hacker News new | ask | show | jobs
by pdonis 858 days ago
> I'm going to go back to learning more C and Forth

Why would you expect that to decrease the number of syscalls you need? The syscalls are there because the program needs the OS to do things. That need is driven by the application domain, not by the programming language you use.

3 comments

> The syscalls are there because the program needs the OS to do things.

Maybe some of them are. Many of those syscalls are there because Python (not the core program someone is creating, but rather its platform) needs the OS to do things.

Importing an empty python file takes 28 syscalls (30 measured by their tool, but the last two are closing out the trace not actually related to the import). 29 syscalls if you have any text in it (presumably more for larger files).

The logical equivalent in C for many portions of the import process in Python happen at compile + linker time, not during execution. So while it might not be a pleasant experience to develop, a C equivalent of many Python programs would involve far fewer syscalls at execution time.

Python's module importing / $PYTHONPATH lookup/traversal is incredibly inefficient, especially with cold FS caches...

I've worked at places where we've significantly patched the logic (in a way which breaks compatibility in some cases, so couldn't be up-streamed) which makes Python startup / module loading with hundreds of paths in $PYTHONPATH orders of magnitude faster...

Unless the programming language you use happens to perform 20,000 system calls before it ever even runs a line of your actual code...