python code quality

46 views
Skip to first unread message

Daniel Ölschlegel

unread,
Mar 17, 2014, 11:43:41 AM3/17/14
to android...@googlegroups.com
Hi all,
i'm unsure is this the right place for this kind for discussion but i looked on code of some python files especially build/tools and it looks often strange.

Some samples:
product_debug.py: missing comma in "PRODUCT_MODEL" line
findleaves.py: performance over readable or why is the check_prunce so long instead a simple onliner like dirs = filter(lambda dir: dir not in prune, dirs)

general: many outputs are constructed with "+" instead of string formating
general: some open&close constructs instead of with
general: when Python 3 is a future goal, you should switch to print function (also available in Python2).

Glenn Kasten

unread,
Mar 17, 2014, 11:58:25 AM3/17/14
to android...@googlegroups.com
Since most of these are relatively small issues, I suggest you start uploading small "surgical" CLs to address the issues you find.
I recommend keeping them small and isolated to one topic at a time, and that you focus on the clearly incorrect things first,
before stylistic improvements.  Thanks.  See https://source.android.com/source/life-of-a-patch.html

Joe Onorato

unread,
Mar 17, 2014, 3:03:14 PM3/17/14
to android...@googlegroups.com
For the findleaves.py one, I don't know if filter will be faster than
the code that's there, but that function is performance critical for
the build system. It is called thousands of times when reading the
platform makefiles, so if you're going to submit a change for that
one, there can not be any performance regressions.

Joe
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Contributors" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-contr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages