4 ms·
$ time python -c 'print(1)' 1 real 0m0.067s user 0m0.015s sys 0m0.025s Is it slow? That was Python 2.7.10, and for me Python 3.6 is similarly fast.
by sillysaurus3 9y ago
$ time python -c 'print(1)'
1
real 0m0.067s
user 0m0.015s
sys 0m0.025s
Is it slow? That was Python 2.7.10, and for me Python 3.6 is similarly fast.
- JasonSage 9y agoIf you had read the article, you would see that the topic of discussion is reducing startup time when many modules are loaded due to the slow nature of `namedtuple`.
- agumonkey 9y agoMaybe only slow when importing. With mainstream pip it's often that you leverage imports a lot.
- deleted 9y ago[deleted]
- benhoyt 9y agoOn my system (macOS) I see a minimum of 0m0.034 for Python 3.6.1 and a minimum of 0m0.022 for Python 2.7.13 -- so Python 3.6 is 50% slower. This is a somewhat contrived example, however. As the article notes, it's worse when you have a lot of imports (and I don't know how that'd differ between versions 2 and 3). I remember talking to some folks at Google who work on the Google Cloud CLI, and they said that Python startup time is a constant problem for their (large) codebase. Especially when it's used for tab completion, because it might run every time you press tab, and the user wants instant results.
- sillysaurus3 9y agoAha, tab completion makes sense. Thanks!
- mikepurvis 9y agoWe're dealing with this on a CLI build tools project I hack on (catkin_tools). It uses plugin discovery based on entry_points, and short of caching plugins in a homedir file, it's basically impossible to make it fast enough to use with something like argcomplete. Relevant ticket: https://github.com/catkin/catkin_tools/issues/297 https://github.com/catkin/catkin_tools/issues/297
- smcl 9y agoWhy on earth would they think invoking a new interpreter each time someone hits "tab" would do anything except perform suboptimally?
- sreque 9y agoI spent a lot of time analyzing the startup time of Java, Python, and Node.js. For any real-world program, startup time is entirely dominated by time taken to load code into memory, which in python is import statements. Also, as slow as Python 2.7 is, Node.js, at least when I measured it, was twice as slow.
- draegtun 9y agoHere's some benchmarks i've come across - http://onetom.rebol.info/2013/08/18/startup-time-of-interpreters/ http://onetom.rebol.info/2013/08/18/startup-time-of-interpre...
- paulsutter 9y agoThe discussion is about import speed, which is a real problem: $ time python3 -c 'import tensorflow' real 0m4.522s user 0m1.712s sys 0m0.466s