Unify BINARY_OP bytecodes by ShaharNaveh · Pull Request #6317 · RustPython/RustPython
597-599: LGTM! Instruction unification aligns with CPython.
The unification of BinaryOperation and BinaryOperationInplace into a single BinaryOp instruction correctly implements the CPython approach referenced in the PR objectives.
1094-1105: LGTM! Documentation example is now correct.
The documentation example correctly imports the required types and demonstrates proper usage of the BinaryOp instruction. This addresses the previous review feedback.
1107-1161: LGTM! Complete operator set with clear documentation.
All 13 basic binary operators and their 13 in-place variants are properly defined with clear symbol documentation. The enum values (0-25) are sequential and fit well within the u8 representation.
1174-1191: LGTM! Complete and correct mapping in as_inplace().
All 13 non-inplace operators correctly map to their in-place equivalents, and the wildcard arm properly handles operators that are already in-place. This addresses the previous review feedback about the missing And => InplaceAnd mapping.
1194-1226: LGTM! Comprehensive Display implementation.
All 26 operators have their correct string representations, making disassembly output clear and readable. The implementation correctly distinguishes between non-inplace (e.g., "+") and in-place (e.g., "+=") operators.
1622-1622: LGTM! Stack effect correctly unified.
The unified BinaryOp instruction correctly returns a stack effect of -1, which is appropriate for all binary operations (pop 2 operands, push 1 result).
1827-1827: LGTM! Improved disassembly formatting.
The formatting now uses the Display trait implementation, producing clearer output with operator symbols (e.g., "BINARY_OP +" or "BINARY_OP +=") instead of enum variant names.