4 ms·
The JVM memory cost is generally paid only once. Python doesn't have an effective thread implementation, but Java does. And, of course, CPU usage of Python is
by SwellJoe 17y ago
The JVM memory cost is generally paid only once. Python doesn't have an effective thread implementation, but Java does.
And, of course, CPU usage of Python is pretty much unarguably higher than Java for most things, assuming well-written code in each language.
- rbanffy 17y agoI thought that in any modern OS you would have the libraries loaded only once and the only thing that is multiplied across processes (or threads) is the working data for that specific thread or process. The overhead should be minimal. If not, it's an OS problem outside the domain of the Java and Python maintainers. What we are apparently seeing is that the working data is larger in Python.
- wmf 17y agoI thought that in any modern OS you would have the libraries loaded only once and the only thing that is multiplied across processes (or threads) is the working data for that specific thread or process. You'd think that, but apparently mmaping bytecode would be too easy for the JVM people so each process copies all its bytecode into its heap (modulo the class data sharing kludge). I think Ruby also enjoys this misfeature and I wouldn't be surprised if CPython does the same. What we are apparently seeing is that the working data is larger in Python. Not surprising since a Java object is a struct but a Python object is more like a hash table.
- blasdel 17y agoPython objects are dicts by default, but become essentially structs if you use __slots__