min_key.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright 2010-present MongoDB, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """Representation for the MongoDB internal MinKey type.
  15. """
  16. class MinKey(object):
  17. """MongoDB internal MinKey type.
  18. .. versionchanged:: 2.7
  19. ``MinKey`` now implements comparison operators.
  20. """
  21. _type_marker = 255
  22. def __eq__(self, other):
  23. return isinstance(other, MinKey)
  24. def __hash__(self):
  25. return hash(self._type_marker)
  26. def __ne__(self, other):
  27. return not self == other
  28. def __le__(self, dummy):
  29. return True
  30. def __lt__(self, other):
  31. return not isinstance(other, MinKey)
  32. def __ge__(self, other):
  33. return isinstance(other, MinKey)
  34. def __gt__(self, dummy):
  35. return False
  36. def __repr__(self):
  37. return "MinKey()"