MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / _CursorAddress

Class _CursorAddress

pymongo/message.py:1874–1900  ·  view source on GitHub ↗

The server address (host, port) of a cursor, with namespace property.

Source from the content-addressed store, hash-verified

1872
1873
1874class _CursorAddress(tuple[Any, ...]):
1875 """The server address (host, port) of a cursor, with namespace property."""
1876
1877 __namespace: Any
1878
1879 def __new__(cls, address: _Address, namespace: str) -> _CursorAddress:
1880 self = tuple.__new__(cls, address)
1881 self.__namespace = namespace
1882 return self
1883
1884 @property
1885 def namespace(self) -> str:
1886 """The namespace this cursor."""
1887 return self.__namespace
1888
1889 def __hash__(self) -> int:
1890 # Two _CursorAddress instances with different namespaces
1891 # must not hash the same.
1892 return ((*self, self.__namespace)).__hash__()
1893
1894 def __eq__(self, other: object) -> bool:
1895 if isinstance(other, _CursorAddress):
1896 return tuple(self) == tuple(other) and self.namespace == other.namespace
1897 return NotImplemented
1898
1899 def __ne__(self, other: object) -> bool:
1900 return not self == other

Calls

no outgoing calls