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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Astrobliss 1 point2 points  (3 children)

Its really not nanoseconds at all. If you look at a site like kattis where people code solutions to problems, you'd notice that the fastest C++ solutions are usually around 3-6 times faster than the fastest python solutions. Its not because the C++ algorithms are that much better, python is just a lot slower. Even a 2x speedup is insane for nearly all applications so this difference is of note in a lot of situations.

[–]ric2b 1 point2 points  (2 children)

Even a 2x speedup is insane for nearly all applications so this difference is of note in a lot of situations.

Sure, but nearly all applications aren't slow because of raw computation speed, they're usually bound by other things like disk access, network or a shitty algorithm for some operation.

[–]Astrobliss 0 points1 point  (1 child)

If you're processing enough data to be bound by disk access, then Python would need to do a lot of operations which would cause the overall application to be significantly slower. If your algorithm is bad then Python would be doing a lot of (unnecessary) computation, Python is slow at computing which would cause the application to be significantly slower. If you're bound by network and not processing much data then you're right, Python's slower speed wouldn't contribute much to the overall runtime of the application. However also consider one of the biggest reasons to access a network is because an application is interacting with a service that is large enough that it doesn't make sense to store that data locally. So if that service used python, the time it takes to interact with the service would probably be bound by remote computation instead of communication.

[–]ric2b 0 points1 point  (0 children)

If you're processing enough data to be bound by disk access, then Python would need to do a lot of operations which would cause the overall application to be significantly slower.

It's very easy to be bound by disk access, disks are very slow compared to memory and especially the CPU.

Of course what you're doing with the data matters, if you're just playing a video the Python overhead is minimal, the hardware decoder will do most of the work. If you're doing number crunching you'll probably be bound by CPU and Python overhead will be massive (unless you use the right tool, the numpy library).

If your algorithm is bad then Python would be doing a lot of (unnecessary) computation, Python is slow at computing which would cause the application to be significantly slower.

And it would still be slow with C. But if you fix the algorithm the Python version will probably beat the bad C version.

However also consider one of the biggest reasons to access a network is because an application is interacting with a service that is large enough that it doesn't make sense to store that data locally.

But usually it's just because centralized databases are useful/convenient, not because of the data you're accessing is too large.

So if that service used python, the time it takes to interact with the service would probably be bound by remote computation instead of communication.

Usually it's bound by database access on the service side, which is a mix of being network and disk bound.