Default heuristics for variable-format displays

Tony Nelson tonynelson at georgeanelson.com
Tue Sep 15 18:35:32 UTC 2009


On 09-09-15 12:06:54, Adam Jackson wrote:
 ...
> def mode_dpi_cmp(x, y):
> 	return cmp(abs(x.dpi - 96), abs(y.dpi - 96))
 ...

The names x and y suggest coordinates to me.  I'd have read the code 
right the first time if the names had been a and b.

> def best_mode(modes, dpi_known = True):
> 	l = filter(lambda x: x.refresh >= 72, modes)


If the sort is stable, how about sorting by highest refresh rate first? 
That way an 85 Hz refresh (if available) would be preferred over a 75 
Hz refresh rate.  (I expect the 72 Hz is to separate out LCDs which 
usually have a fixed rate of about 60 Hz.)

        l = filter(lambda a: a.refresh >= 72, modes).sorted(
            key=lambda a: -a.refresh )

(BTW, use key instead of cmp in the other cases as well.)

> 	if l == []:
> 		l = modes
> 	if dpi_known:
> 		l.sort(cmp=mode_dpi_cmp)
> 	else:
> 		l.sort(cmp=mode_size_cmp)
> 	return l[0]
 ...

In any case, thank you for working on it (my bz is 522155 "RFE choose
sensible resolution during boot").

-- 
____________________________________________________________________
TonyN.:'                       <mailto:tonynelson at georgeanelson.com>
      '                              <http://www.georgeanelson.com/>




More information about the fedora-devel-list mailing list