lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andi Vajda <>
Subject Re: Automatic typecasting of int to float
Date Sat, 14 Dec 2013 19:59:02 GMT

> On Dec 14, 2013, at 16:46, Petrus Hyvönen <> wrote:
> Hi!
> I am converting some java code to python scripts, using a JCC wrapped library.
> One thing that strikes me is that java seems to have a automatic typecast of int to float,
which is not present in the JCC wrapped library.
> i.e. if a tmp=100 and obj.shift(tmp) is executed, and the method expects a float, it
seems to fail in the wrapped code while working in java. Of course it can be explicitly typed
obj.shift((float) tmp) but it does look as readable.

In python, no, that syntax is incorrect. But you could use 100.0 instead of 100. Almost as
readable. Or add an intermediate method that casts to float.

Could that feature be added to jcc ? sure, but it gets complicated fast. If you control both
ends of the app (the python and the java code), it's easiest to add an int overload to the
shift method and call the float version.


> This is a minor thing, but could it be enabled so that this automatic conversion from
int to floats are done if no other matching signatures are found? (I assume this is the way
java works, I'm no java expert..) 
> Many thanks
> /Petrus

View raw message