-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TBool -> TInt casts/conversions #736
Comments
@jordens Can you live without that for PDQ3? |
I can. But people won't like it. It's wrong. And I fear it will just end up on the pile of unresolved issues. |
Sure, but considering the current situation I don't think we can fix that in time for 3.0. |
I'd rather delay 3.0 than ship it with issues like these. |
Is there someone else affected by this? @dhslichter @cjbe @jbqubit @hartytp @r-srinivas are you using Python booleans as integers? |
@sbourdeauducq You will need to supply more context and explain the issue and the general consequences if you want to have a vote on this. |
It's quite simple, in Python you can do integer operations on booleans directly, with
Currently in ARTIQ-Python this does not work and you get a type error; you must convert the booleans to integers explicitly instead. |
There is more people should know:
|
How will APIs be broken? |
@kernel
def set_clr(self, clr0: TInt32, clr1: TInt32, clr2: TInt32):
... will become @kernel
def set_clr(self, clr0: TBool, clr1: TBool, clr2: TBool):
... |
You can make it |
IIRC explicit conversions are broken as well. There would need to be ifs... |
Also it's harsh of you to say that compiler issues are "systematically" delayed; look at the commit log for April 22 to see some counter-examples. |
I didn't say that! That was a policy question, not a blanket statement about the past. To me a compiler where I don't have to worry that much about hitting and then circumnavigating unexpectedly buggy or slow behavior is at the top of my wishlist. Let me rephrase it: How important are compiler bugs to people and can we ignore them for now if there are workarounds? |
@sbourdeauducq I have hit this before, however it is one of the more understandable compiler bugs to work around. Things like #685 and #719 are more important to me in terms of removing recurring pain. |
I am with @cjbe, things like #407, #685, and also #719 are more important to our day-to-day usage. I don't use booleans as integers, at least not in the way that @jordens is describing in the initial post. I think there is a balance to be struck between allowing for all the things Python does in ARTIQ Python, and making things too restrictive in ARTIQ Python, but this seems like a fairly simple thing for someone to figure out what's happening and adjust their code appropriately, and I guess I wouldn't delay the 3.0 release for this. I think explicit conversions (e.g. |
I think the only time we've hit this is at some point we were setting up some chip selects with ttls and I think |
I concur with @dhslichter and @cjbe. |
On NAC3: ...
def run() -> int32:
output_int32(True << 1)
return 0 errors out with:
(and same thing with Explicit conversions work: def run() -> int32:
output_int32(int32(True))
output_int32(int32(False))
output_int64(int64(True))
output_int64(int64(False))
return 0
|
In CPython
True << 1 == 2
.In ARTIQ Python:
Explicit conversions are also broken:
The text was updated successfully, but these errors were encountered: