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

Avoid problematic uses of 'is' #112

Merged
merged 1 commit into from
Feb 13, 2020
Merged

Commits on Feb 12, 2020

  1. Avoid problematic uses of 'is'

    The 'is' operator compares by object identity, which is not usually
    what you want unless comparing with singleton objects like None.
    Python 3.8 warns about suspicious uses of 'is' during byte-compilation.
    
    As an implementation detail, CPython interns small integers, so
    "1 + 1 is 2" is likely to be true, although this is not an API guarantee.
    
    However, "field is 'comment'" is unlikely to be true, because CPython
    allocates separate string objects for each instance of the same long
    string.
    
    Signed-off-by: Simon McVittie <[email protected]>
    smcv committed Feb 12, 2020
    Configuration menu
    Copy the full SHA
    f3ac68f View commit details
    Browse the repository at this point in the history