(
&mut self,
vm: &VirtualMachine,
op: bytecode::ComparisonOperator,
)
| 7261 | |
| 7262 | #[cfg_attr(feature = "flame-it", flame("Frame"))] |
| 7263 | fn execute_compare( |
| 7264 | &mut self, |
| 7265 | vm: &VirtualMachine, |
| 7266 | op: bytecode::ComparisonOperator, |
| 7267 | ) -> FrameResult { |
| 7268 | let b = self.pop_value(); |
| 7269 | let a = self.pop_value(); |
| 7270 | let cmp_op: PyComparisonOp = op.into(); |
| 7271 | |
| 7272 | // COMPARE_OP_INT: leaf type, cannot recurse — skip rich_compare dispatch |
| 7273 | if let (Some(a_int), Some(b_int)) = ( |
| 7274 | a.downcast_ref_if_exact::<PyInt>(vm), |
| 7275 | b.downcast_ref_if_exact::<PyInt>(vm), |
| 7276 | ) { |
| 7277 | let result = cmp_op.eval_ord(a_int.as_bigint().cmp(b_int.as_bigint())); |
| 7278 | self.push_value(vm.ctx.new_bool(result).into()); |
| 7279 | return Ok(None); |
| 7280 | } |
| 7281 | // COMPARE_OP_FLOAT: leaf type, cannot recurse — skip rich_compare dispatch. |
| 7282 | // Falls through on NaN (partial_cmp returns None) for correct != semantics. |
| 7283 | if let (Some(a_f), Some(b_f)) = ( |
| 7284 | a.downcast_ref_if_exact::<PyFloat>(vm), |
| 7285 | b.downcast_ref_if_exact::<PyFloat>(vm), |
| 7286 | ) && let Some(ord) = a_f.to_f64().partial_cmp(&b_f.to_f64()) |
| 7287 | { |
| 7288 | let result = cmp_op.eval_ord(ord); |
| 7289 | self.push_value(vm.ctx.new_bool(result).into()); |
| 7290 | return Ok(None); |
| 7291 | } |
| 7292 | |
| 7293 | let value = a.rich_compare(b, cmp_op, vm)?; |
| 7294 | self.push_value(value); |
| 7295 | Ok(None) |
| 7296 | } |
| 7297 | |
| 7298 | /// Read a cached descriptor pointer and validate it against the expected |
| 7299 | /// type version, using a lock-free double-check pattern: |
no test coverage detected