ironpython3 icon indicating copy to clipboard operation
ironpython3 copied to clipboard

Add support for e format in _struct

Open slozier opened this issue 3 years ago • 5 comments
trafficstars

See https://docs.python.org/3/whatsnew/3.6.html#struct

https://github.com/IronLanguages/ironpython3/pull/1457 adds support to .NET 6.0 (via System.Half).

slozier avatar May 17 '22 00:05 slozier

#1457 adds support to .NET 6.0 (via System.Half).

I wonder what Half will do to the overload resolution rules...

Also I see Half supported from .NET 5 up. Does it mean we do not support net5.0 anymore?

BCSharp avatar May 17 '22 03:05 BCSharp

#1457 adds support to .NET 6.0 (via System.Half).

I wonder what Half will do to the overload resolution rules...

I'm not sure if it'll impact overload resolution. I think it's just a struct with explicit casts to/from floats.

Also I see Half supported from .NET 5 up. Does it mean we do not support net5.0 anymore?

.NET 5 doesn't have the BitConverter overloads to go to/from bytes. But yes, we can remove it and save a bit of CI time (though I need to look at .NET 7 again).

slozier avatar May 17 '22 11:05 slozier

I'm not sure if it'll impact overload resolution.

Just tested a bit by hacking BinderTest. Overloads using Half are not accepting any numeric values (float or otherwise). Also, I cannot create any instances of Half (except zero). I suppose it need to be added to FloatOps. Maybe it is worth a separate Issue?

BCSharp avatar May 17 '22 17:05 BCSharp

I'm not sure if it'll impact overload resolution.

Just tested a bit by hacking BinderTest. Overloads using Half are not accepting any numeric values (float or otherwise). Also, I cannot create any instances of Half (except zero). I suppose it need to be added to FloatOps. Maybe it is worth a separate Issue?

Right, but I don't think C# has language support either, the only(?) way to get a non-zero Half is by casting, for example you can't write Half.IsNaN(1.0), has to be Half.IsNaN((Half)1.0). As for creating instances in IronPython I think you can do a cast like this: clr.Convert(1.2, System.Half). We could potentially add a convenience constructor like we do for other numeric types but that is indeed a separate issue (or just a PR).

slozier avatar May 17 '22 21:05 slozier

As for creating instances in IronPython I think you can do a cast like this: clr.Convert(1.2, System.Half). We could potentially add a convenience constructor like we do for other numeric types but that is indeed a separate issue (or just a PR).

OK, clr.Convert works for me.

BCSharp avatar May 17 '22 23:05 BCSharp