Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Relative performance of Python2 vs. Python3
-
@Phuket2 Wow, you're lucky. On my iPad mini, when I run the script with size 16 on Python 3, it takes 5 minutes to run...
-
@dgelessus , that's an amazing difference. I have been so impressed with my iPad Pro, screen score, speed and battery performance. The battery is the same performance as my iPad Air 2. Britney's settings always the same both devices. I get 10/11 good hours out of my battery. Only difference between the 2 is that the Pro takes a lot longer to charge than the air.
Here is an interesting list if you are interested. Geek bench test comparison for iOS devices
http://browser.primatelabs.com/ios-benchmarks -
@Phuket2 I am surprised if Python 3 ran faster for you than Python 2.
Could you please redownload the code and running it again? I modified it to print the version of Python that is running. If you are in Pythonista 3 beta then you need to modify the first line of the script to read
python2
instead ofpython3
to force Pythonista to use of Python 2. -
I'm seeing similar results, and unfortunately, I have neither a good explanation, nor a solution at the moment.
I've experimented a little bit with enabling additional compiler optimizations for the Python 3 branch. That does result in a ~20% speedup (from 1:10 to 0:59), but it's still significantly slower than running it with Python 2 (0:35). Interestingly, changing the integer literals to explicit longs in Python 2 brings it down to 0:50, so very close to Python 3, where all integers are longs, but that doesn't really explain why there isn't much of a difference on the desktop...
-
Implementing this in "fragment shader" would run in less than a fraction of a second. See
the following gist for an implementation.
https://gist.github.com/balachandrana/82f643e38326ce9e7ce720e399b34caeIt may not be directly related to python 2/python 3 performance comparison topic. But
"fragment shaders" are well suited for implementing these kind of problems. For learning about
"fragment shaders" the book of Shaders (http://patriciogonzalezvivo.com/2015/thebookofshaders/) is
the best place to start with. The following tutorials from shadertoy are also good for beginners. -
I've made some progress. It turns out that Python 3 was compiled with pymalloc disabled.
Enabling it (as in the Python 2.7 build) results in a pretty significant speedup. Now I'm getting 0:41 from Python 3, which is quite a bit closer to Python 2 (0:35), and the ratio is very similar to what @ccc is seeing on the MacBook Pro.
-
Awesome work both of you!!!
@abcabc I posted some suggestions as a comment on the gist on how to be a bit more full screen.
Is there a similar way to use to the hardware of a Mac from Python?!? Your speedup is incredible!
@omz I think your speedup is great news for us all! We all want to move to Python 3 ;-) Right?!?
-
@ccc I'm certainly eager to move to Py3. I'm trying to do it all without 2to3, as well as to keep backwards compatibility, because it's a good way to learn imo
-
@ccc @abcabc The shader is great! I've made a resolution-independent fork that renders full-screen on all devices. The hard-coded 600x600 size probably doesn't work well on iPhone.
-
@omz, @ccc Thanks for your suggestions.
Is there a similar way to use to the hardware of a Mac from Python?!?
Pyglet is supposed to be good for opengl. There seems to be simple wrapper for
GLSL (see the url below), but I have not tried it.
https://groups.google.com/forum/#!topic/pyglet-users/3x8rYF7pNC4