
Python for Android - fabriceleal
http://python-for-android.readthedocs.org/
======
aswanson
A bigger question on my mind has been why would a shop as smart as Google not
have started out with a sane language like python in the first place instead
of foisting this java idiocy on another generation of devs.

~~~
nly
Java has a granular, stable and simple byte code, Python does not. Java is
amenable to static analysis, mainline Python isn't. Dynamic typing means more
runtime, burns more battery.

Java also allowed them to leverage a mature and highly optimized frontend.
Back in 2008, Psyco/PyPy was there... but fairly wet. Until recently(?) the
primary JIT back-end for PyPy was, in fact, still the JVM.

~~~
jnbiche
>"Until recently(?) the primary JIT back-end for PyPy was, in fact, still the
JVM."

That's not true -- PyPy had an experimental JVM backend early-in, but the
first and flagship backend has always been the RPython one.

~~~
voidlogic
Maybe he is thinking of Jython?

~~~
nly
You're correct, I was muddling up the projects (I really don't use or have an
interest in Python)

I thought RPython was only translated to C and compiled ahead-of-time.

~~~
jnbiche
You're right about that. To make a more correct analogy, I should have said
that the main target has always been C, which RPython "transpiles" into. So
the original and primary target has always been portable C, but there have
also been experimental JVM, CLR, and JavaScript targets.

------
limmeau
Compare this with the late PyS60, where you installed a little SIS on your
phone, 2MB or so, and could then run simple Python scripts. Forwarding all
incoming SMSs to another phone number was a six-liner or so.

I've never used it to build big apps, only toyed around with examples, but
then again, it wasn't made for the big applications, rather for small ad-hoc
scripts.

Kind of Eclipse plugins vs Emacs scripts.

------
dylangs1030
I don't use Android devices, so I wouldn't know, but is this the first
instance of mobile Python on Android OS?

Jailbroken iPhones have had this capability for years...not to say iOS is
better, just that I'd expected this would happen...sooner?

That said, the Python distro on iOS is only 2.6-ish, not even 2.7, and there's
no 3.x release there. It's not very useful but I guess I did use it a lot for
learning back then.

~~~
myko
Python has been on Android for a long time. The first instances I know of is
SL4A: [https://code.google.com/p/android-
scripting/](https://code.google.com/p/android-scripting/)

Kivy for Android has been around awhile as well.

~~~
knappador
Kivy developers are the primary movers behind Python for Android. Typically we
are using Cython so that a great deal of the application is actually running
in C without the Python runtime eating up overhead. This leaves a budget of
about a million function calls per second, or roughly 10,000 per frame, as
most of the overhead in the UI thread is eaten up in expensive function stack
frame in the event system, passing around events that call callbacks that call
callbacks that call callbacks...

It remains to be seen if we can adopt a concurrent model for some aspects of
the main application thread(s). Going concurrent almost surely means more
Cython and more speed. I'm interested if anyone has any ideas about using
CPython to reduce the cost of certain nearly-always-performed functions to
grease the event system. Not that it's slow, but fast is always better =)

[http://kivy.org/#home](http://kivy.org/#home)

------
daGrevis
This is really cool!

I'm interested in creating daemons that, for example, forwards SMSes to my
email and records made voice calls. Is API good enough to do that?

~~~
jnbiche
Yes. Daemons are the one implementation where Python's longish start-up time
on Android won't make any difference (we're talking a few seconds here, versus
under a second for native Android apps, just to be clear). If anything you
need is missing from the API, you can use Pyjynius to do easy Java interop.

Another options for this kind of app is SL4A. They have a very complete
Android API, but it's a bit harder to hack and not as well documented.

If you want to package an APK, I think this project (Kivy's Python for
Android) is probably a slightly better option. You can package APKs with SL4A,
but it's a bit trickier. Python for Android even provides a virtual box image
of Ubuntu (or Debian, I don't remember) for building APKs, with all the
dependencies included, ready to go.

~~~
daGrevis
So I'm good to go. A pretty big challenge for me, but I will handle it at some
weekend for sure! :)

