Skip to content
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

Ternary expression (A if B else C) bug report #7

Closed
lego0901 opened this issue Feb 26, 2021 · 1 comment
Closed

Ternary expression (A if B else C) bug report #7

lego0901 opened this issue Feb 26, 2021 · 1 comment

Comments

@lego0901
Copy link
Contributor

아래와 같은 코드 실행에서 문제가 발생한다는 것을 깨달았습니다.

x = 0 if 0 <= 1 else 1
# runtime output
REDUCED HEAP: (size: 250)
  x => 1

파이썬의 삼항연산자가 x = (((0 <= 1) and 0) or 1)로 파싱됩니다.
Logical statement가 True, true-value가 0일 때 발생하는 오류인 것으로 보입니다.

당장 벤치마크 코드에서 나타나는 문제는 아닙니다.
Pylib builtin 구현에서 발생한 문제이므로, 다른 방식으로 구현함으로써 일단은 피해갈 수 있을 것 같습니다.

감사합니다.

@MerHS
Copy link
Collaborator

MerHS commented Feb 28, 2021

function call로 바꿔서 해결

@MerHS MerHS closed this as completed Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants