This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH][RFC] Implement benchmark script in python
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: Mike Frysinger <vapier at gentoo dot org>
- Cc: libc-alpha at sourceware dot org, carlos at redhat dot com
- Date: Thu, 19 Dec 2013 20:14:32 +0530
- Subject: Re: [PATCH][RFC] Implement benchmark script in python
- Authentication-results: sourceware.org; auth=none
- References: <20131206085334 dot GF14845 at spoyarek dot pnq dot redhat dot com> <201312190906 dot 12693 dot vapier at gentoo dot org>
On Thu, Dec 19, 2013 at 09:06:11AM -0500, Mike Frysinger wrote:
> i have no problem utilizing python in any place that does not impact:
> tar xf glibc.tar.bz2 && cd glibc && ./configure && make && make check
>
> for larger scripts, python is certainly easier to maintain
>
> that said, this is the first python we've imported, so i think we need to nail
> down some general python things before we allow it. thus proposed:
> - use PEP8 style. that means no tabs for indentation.
> - use PEP257 for docstrings. here's the preferred format:
> """One line description.
>
> Longer details go here on multiple lines.
>
> Args:
> arg: description of it
>
> Returns:
> Describe the return value.
>
> Raises:
> Any random exceptions that might be raised.
> """
> - require python-2.7, but be compatible with python-3.2+
> - use "from __future__ import print_function"
> - use printf strings rather than concatenation:
> bad: print('blah' + var + 'foo')
> good: print('blah%sfoo' % var)
> - prefer strings use single quotes rather than double quotes
> - use a main() func
> - global scope code is heavily discouraged
> - globals are heavily discouraged
> - let's add a pylintrc file and require all code to pass `pylint` with it
Thanks for the detailed review! I'll post an updated script soon-ish.
>
> > # Look for directives and parse it if found.
> > if line.startswith("##"):
> > _parse_directive(line[2:].split(':', 1))
> >
> > # Skip blank lines and comments.
> > if not line or line[0] == '#':
> > continue
>
> what about inline comments ? or are those not supported ?
> line = line.split('#', 1)[0].rstrip()
> if not line:
> # it's a comment or blank
>
They weren't supported in the perl script, but it won't be a bad idea
to have.
Siddhesh