[ann] Minimal Python project

Jimmy Retzlaff jimmy at retzlaff.com
Wed Jan 15 00:24:17 CET 2003


Skip Montanaro wrote:
>   Jimmy> Psyco created two specialized versions of my function - one
for
>   Jimmy> use with integers and another for use with floating point
>   Jimmy> numbers.
>
> Which, depending on the particular computation, might differ
semantically
> from one another, what with floating point inaccuracies and all.
> ...

Isn't this issue inherent in Python and not introduced by Psyco? I was
actually calling the function in question with objects of type int in
some cases and with objects of type float in other cases. Hence the
potential differences were already there before Psyco (but not an issue
in my particular case). I don't think Psyco changed the situation.

My C version did have potential semantic differences from the Python
version in that parameters to it were always coerced to doubles. Hence
any distinctive int parameter behavior was lost (again not an issue in
my particular case).

Now if Psyco were so aggressive as to look at parameter values and
decide that, for example, 17.0 could be treated as an object of type
int, then there indeed could be serious issues. This would be especially
true if uses of the operator / were present without "from __future__
import division" or if magnitudes were large enough to induce any
overflow behavior. I don't see any other issues off the top of my head,
but I'm certainly not an expert on the intricacies of binary floating
point.

Jimmy





More information about the Python-list mailing list