classification
Title: Enhancing performance and memory usage
Type: enhancement Stage:
Components: Interpreter Core Versions: Python 3.3
process
Status: closed Resolution: works for me
Dependencies: Superseder: Verify all imported modules at startup are needed
View: 16101
Assigned To: Nosy List: Ramchandra Apte, Sworddragon, georg.brandl
Priority: normal Keywords:

Created on 2013-01-09 12:31 by Sworddragon, last changed 2013-01-09 13:09 by georg.brandl. This issue is now closed.

Messages (3)
msg179435 - (view) Author: (Sworddragon) Date: 2013-01-09 12:31
On my system (Linux 64 Bit) I figured out that python 3 needs a little more memory than python 2 and it is a little bit slower. Here are some examples:

sworddragon@ubuntu:~$ execution-time 'python2 -c print\("0"\)'
0.21738
sworddragon@ubuntu:~$ execution-time 'python2 -OO -c print\("0"\)'
0.22559
sworddragon@ubuntu:~$ execution-time 'python3 -c print\("0"\)'
0.37962
sworddragon@ubuntu:~$ execution-time 'python3 -OO -c print\("0"\)'
0.37825

Checking the memory usage after python 2 and python 3 are started in a terminal shows the following:

python2: RES 4780 / SHR: 2212
python3: RES 6168 / SHR: 2660
msg179437 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2013-01-09 13:04
What is the problem? 
Python 3 uses more memory because many things that were earlier ASCII strings in Python 2 are Unicode strings. Same reason for performance AFAIK.
msg179438 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2013-01-09 13:09
The "performance" you're measuring here is mostly startup, i.e. loading all necessary modules.  On Python 3, there is more to load, e.g. the filesystem encoding, therefore startup takes a little longer.

There are efforts to improve startup time, see e.g. #16101.

The memory consumption is expected, again due to more modules loaded.  You cannot make any statement about the memory usage of a real-world application by just measuring the overhead of the interpreter.

The memory usage due to strings should be very similar to Python 2 starting with Python 3.3, due to PEP 393.
History
Date User Action Args
2013-01-09 13:09:44georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg179438

superseder: Verify all imported modules at startup are needed
resolution: works for me
2013-01-09 13:04:43Ramchandra Aptesetnosy: + Ramchandra Apte
messages: + msg179437
2013-01-09 12:31:57Sworddragoncreate