[Piglit] [PATCH 2/4] arb_shader_precision: add framework for calculating tolerances for complex functions

Ilia Mirkin imirkin at alum.mit.edu
Thu Feb 19 11:27:38 PST 2015


On Thu, Feb 19, 2015 at 2:16 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> On Thu, Feb 19, 2015 at 02:03:41PM -0500, Ilia Mirkin wrote:
>> On Thu, Feb 19, 2015 at 12:59 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
>> >> +            return -1.0 if any(ret['badlands']) else map(float,
>> >> ret['component_tolerances'])
>> >
>> > Generally at this point python (both upstream and community) discourage
>> > the use of map and filter, with a preference for comprehensions.
>> > [float(x) for x in ret['component_tolerances']] should be what you want.
>>
>> Just to provide a counterpoint, I think that
>>
>> map(float, fooarray)
>>
>> is a ton more readable than
>>
>> list(float(x) for x in fooarray)
>
> I agree that list(generator) is ugly, which is why I suggested a list
> comprehension, and not a generator comprehension.

Ah. But with a list comprehension the variable leaks out, so I tend to
avoid it since it can, in certain situations, create horribly
difficult to track down bugs. But my point still stands -- I prefer

map(float, fooarray)

to

[float(x) for x in fooarray]

Map is a pretty core concept in computer science and math, I think
most people are familiar with it. With the comprehension, I have to
read the whole thing carefully to see if it does something weird.
Anyways, I think, like many things, this comes down to personal
preference, in which case whatever the author of the code likes to do
goes. I think that PEP8 or whatever the doc with "The One And Only
True Way To Write Python" thing is went way too far.

  -ilia


More information about the Piglit mailing list