[Python-Dev] Re: Passing floats to "i" parser marker

Just van Rossum just@letterror.com
Wed, 5 Feb 2003 23:21:20 +0100


Guido van Rossum wrote:

> > for my personal extension code, i actually benefit from the features
> > of automatic float-to-int conversion.
> 
> Can you explain the situation more?  What's your application?  Where
> do the floats come from?

I think one of the reasons the exception got rolled back to a warning
was a comment on the bug by Jack. He mentioned the MacPython IDE (for
which I'm mostly to blame) in which there are lots of calls to Mac
toolbox functions that take geometric values (coordinates, rectangles)
where the units are pixels. There are plenty of cases where the
intermediates for these values have to be floats and it's simply darned
convenient they are chopped to ints. I'm not saying this is good in
_general_, it's just an example of (properly!) working code that is out
there. It's quite a shift to make sure we feed these calls with ints as
often the values are part of tuples (to represent coordinates or
rectangles).

(Jack, here is an idea: why don't we change these Point and Rect
converters to take floats, and do the downcasting in C? Perhaps this is
less work than fixing all Python code. It would actually be quite
appropriate for these calls.)

Just