[Mobile-sig] Pythonic idioms on mobile platforms

David Boddie david at boddie.org.uk
Wed Dec 13 19:15:32 EST 2017

[Answering Russell as well, as I see his response to my original message.]

I can try to be more specific about the problems I found, though I'm not sure
if I really know the best practices for threading in Android (or Python for
that matter).

I was trying to lazily populate items in a scrolling list using instances
of the AsyncTask class, which is a convenient way to do work in a background


I initially thought I was being clever and had found a nice way to handle
processing using background threads. The problem is that, for many items, you
hit a limit where creating new AsyncTasks fails, so the abstraction is quite
brittle and you need to find a way to process a large number of items.

I experimented with using a regular Thread and using queue and communicating
with the main GUI thread using a Handler. This worked fine, but doesn't scale
very well. I ended up returning to the AsyncTask solution and working around
the problem by using a trick familiar to users of desktop GUI frameworks:
posting an event for later evaluation.

One of my points is that getting things done in the GUI tends to involve
techniques that purists would frown on, yet this is something desktop GUI
developers are familiar with. Getting something to work can involve details
that we would prefer not to expose to the user. Given that there is usually
a preferred way to do things with the platform APIs, does that mean that
things like the threading module are effectively obsolete for developers of
mobile GUIs?

Sorry not to be more specific. I'm still trying to wrap my head around some
of these issues.


On Wednesday 13. December 2017 08.12.42 Guido van Rossum wrote:
> Can you be more specific?
> On Dec 13, 2017 8:04 AM, "David Boddie" <david at boddie.org.uk> wrote:
> > I was looking at threading on Android and it occurred to me that perhaps
> > others sidestep problems I encountered with native APIs by using Python's
> > own
> > threading features. Then I wondered if some developers prefer to stick to
> > the
> > platform native APIs for things like threading, and if they found it
> > difficult to adapt to a non-Pythonic API.
> > 
> > Has anyone else looked at how well (or poorly) some of the idioms used in
> > Python map to each of the underlying mobile platforms and frameworks, or
> > are
> > people just using the native APIs directly? The answer to this might save
> > someone the effort of trying to reproduce the APIs of those standard
> > Python
> > libraries that aren't interesting to mobile developers.
> > 
> > David
> > _______________________________________________
> > Mobile-sig mailing list
> > Mobile-sig at python.org
> > https://mail.python.org/mailman/listinfo/mobile-sig

More information about the Mobile-sig mailing list