[Piglit] [PATCH 00/12] cleanup dispatch generation code

Dylan Baker baker.dylan.c at gmail.com
Tue Jan 13 17:50:31 PST 2015


Sorry,

Chad, I meant to CC you on this, since you wrote most of this code.

Dylan

On Tuesday, January 13, 2015 05:48:10 PM Dylan Baker wrote:
> This series is mainly aimed at removing the obsolete cmp function and
> corresponding __cmp__ method, and replace them with rich comparison
> methods (__lt__, __eq__, etc). It also makes some opportunistic cleanups
> of the code, mostly errors in the code, or style changes that are prone
> to turning into surprising behavior.
> 
> Getting rid of cmp is good for a couple of reasons. First it is a very
> course comparison method, it can only know if something is <, >, or ==,
> which it does by returning -1, 1, or 0 (respectively), while rich
> comparisons provide support for <, =<, ==, !=, >=, and >, each as an
> individual method (or, by using functools.total_orderings, with just
> __eq__ and one other method). Second, __cmp__ and cmp were deprecated in
> python 2.1, and are removed in 3.0, so it's a very old spec. Finally, it
> allows objects to be sorted without the use of a key or cmp call to
> sorted(), which makes the code cleaner and easier to understand.
> 
> I have verified that this produces the same output (white space
> unchecked) as before, and that running quick.py all tests were the same,
> except for two known sporadic tests. The only exception is that the
> first patch results in comments changing, but in a way that makes them
> deterministic rather than random.
> 
> This is available at my github:
> https://github.com/dcbaker/piglit submit/remove-registry-cmp
> 
> Dylan Baker (12):
>   piglit-displatch-gen.h.mako: sort comments
>   regirsry/gl.py: remove unused import
>   registry/gl.py: fix no-attribute error
>   registry/gl.py: Replace __cmp__ methods with rich comparison methods
>   registry/gl.py: Strip superfluous parens from the assert keyword
>   registry/gl.py: remove unused variable
>   regsitry/gl.py: Make Error class inherit from Exception
>   gen_dispatch.py: remove unused imports
>   gen_dispatch.py: sort imports into groups
>   gen_dispatch.py: remove use of cmp.
>   gen_dispatch.py: Remove unnecessary parens from assert keyword
>   gen_dispatch.py: silence error
> 
>  registry/gl.py                        | 238 +++++++++++++++++++++++-----------
>  tests/util/gen_dispatch.py            |  60 ++-------
>  tests/util/piglit-dispatch-gen.h.mako |   2 +-
>  3 files changed, 172 insertions(+), 128 deletions(-)
> 
> -- 
> 2.2.1
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20150113/d9162a99/attachment.sig>


More information about the Piglit mailing list