Method
cmp
(
&self,
other: &PyObject,
op: PyComparisonOp,
vm: &VirtualMachine,
)
Source from the content-addressed store, hash-verified
| 294 | } |
| 295 | |
| 296 | pub fn cmp( |
| 297 | &self, |
| 298 | other: &PyObject, |
| 299 | op: PyComparisonOp, |
| 300 | vm: &VirtualMachine, |
| 301 | ) -> PyComparisonValue { |
| 302 | // TODO: bytes can compare with any object implemented buffer protocol |
| 303 | // but not memoryview, and not equal if compare with unicode str(PyStr) |
| 304 | PyComparisonValue::from_option( |
| 305 | other |
| 306 | .try_bytes_like(vm, |other| op.eval_ord(self.elements.as_slice().cmp(other))) |
| 307 | .ok(), |
| 308 | ) |
| 309 | } |
| 310 | |
| 311 | pub fn hash(&self, vm: &VirtualMachine) -> hash::PyHash { |
| 312 | vm.state.hash_secret.hash_bytes(&self.elements) |