Skip to content

Make _Nothing a singleton#433

Merged
hynek merged 5 commits intopython-attrs:masterfrom
LivInTheLookingGlass:feature/_Nothing_singleton
Aug 27, 2018
Merged

Make _Nothing a singleton#433
hynek merged 5 commits intopython-attrs:masterfrom
LivInTheLookingGlass:feature/_Nothing_singleton

Conversation

@LivInTheLookingGlass
Copy link
Copy Markdown
Contributor

I'm not sure how much the checklist makes sense for this change, given that there are no external or internal API changes.

This PR changes the _Nothing class to be a singleton. This allows a shorter class, as well as more reliance on inherited object code. Because they are all the same instance _Nothing() is _Nothing() will be True, and thus _Nothing() == _Nothing() will be True without intervention. This will result in a slight performance boost.

I have confirmed that this breaks no tests on my local machine under both 2.7 and 3.6

This is my first PR for the project, so I apologize in advance if there are any mistakes.

Pull Request Check List

This is just a reminder about the most common mistakes. Please make sure that you tick all appropriate boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!

  • Added tests for changed code
  • New features have been added to our Hypothesis testing strategy.
  • Changes or additions to public APIs are reflected in our type stubs (files ending in .pyi).
    • ...and used in the stub test file tests/typing_example.py.
  • Updated documentation for changed code.
    • New functions/classes have to be added to docs/api.rst by hand.
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • Documentation in .rst files is written using semantic newlines.
  • Changes (and possible deprecations) have news fragments in changelog.d.

If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!

Copy link
Copy Markdown
Contributor

@ambv ambv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@hynek hynek merged commit 4a83c93 into python-attrs:master Aug 27, 2018
@hynek
Copy link
Copy Markdown
Member

hynek commented Aug 27, 2018

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants