Skip to main content


Showing posts from June, 2017

Python is SLOW - How to speed it up - 1

Python is slow. 
For most cases this doesn't really matter as the development time is more of a factor. However on low CPU power devices (phones) anything is significant.

First tip on how to speed up python, is to use Atom!  Just install with pip.  Atom speeds up object creation by about 50% per property (ex an object with 4 properties is about 2x faster, 8 properties 4x, etc...) . I've seen significant performance increases simply by switching in my testing. See the simple example below:
from atom.api import Atom, ForwardInstance, Callable, Unicode, Tuple, Bool, Int, Instance, set_default, Property class TestAtom(Atom): i = Int(1) a = Unicode("abc") b = Tuple(default=(1,2,3)) c = Bool() f = Callable(default=lambda: "test") class TestObj(object): def __init__(self): self.i = 1 self.a = 'abc' self.b = (1,2,3) self.c = False self.f = lambda: "test" %timeit TestAt…

Debugging a crash in a python native library on Android (ex, kivy)

I'm trying to debug a crash in a python extension (cythonized) from pyjnius. The crash signature is as follows:

06-05 18:41:46.111 3631-3631/com.jventura.pyapp I/System.out: + java:invoke(, public abstract void android.text.TextWatcher.beforeTextChanged(java.lang.CharSequence,int,int,int), [Ljava.lang.Object;@c30cd5c) 06-05 18:41:46.113 3631-3631/com.jventura.pyapp I/pybridge: beforeTextChanged called 06-05 18:41:46.114 3631-3631/com.jventura.pyapp A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 3631 (.jventura.pyapp) [ 06-05 18:41:46.114 151: 151 W/ ] debuggerd: handling request: pid=3631 uid=10103 gid=10103 tid=3631 06-05 18:41:46.112 4374-4374/? W/debuggerd: type=1400 audit(0.0:1696): avc: denied { search } for name="com.jventura.pyapp" dev="dm-0" ino=130503 scontex…