⚡ Sangsakala Proxy 🏠 Home
Skip to content

Commit ab819bc

Browse files
committed
Defer tuple iterable folding until constant identity is preserved
Compile-only checks show repeated float constants retain one shared object on CPython 3.14.8 and the prior native path, but this newly enabled fold materializes distinct objects. Revert only the tuple-fold commit and its added IR expectation; keep existing streaming controls, all other compatibility fixes and shared prerequisites. Assisted-by: OpenAI Codex:model identifier unavailable
1 parent 0a50818 commit ab819bc

2 files changed

Lines changed: 7 additions & 33 deletions

File tree

‎crates/codegen/src/compile.rs‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31364,33 +31364,6 @@ def f():
3136431364
)));
3136531365
}
3136631366

31367-
#[test]
31368-
fn large_constant_tuple_iterable_folds_before_get_iter() {
31369-
let source = format!(
31370-
"for x in ({},):\n pass\n",
31371-
(0..31)
31372-
.map(|i| format!("'v{i}'"))
31373-
.collect::<Vec<_>>()
31374-
.join(", ")
31375-
);
31376-
let code = compile_exec(&source);
31377-
assert!(
31378-
code.instructions
31379-
.iter()
31380-
.any(|unit| matches!(unit.op, Instruction::GetIter))
31381-
);
31382-
assert!(!code.instructions.iter().any(|unit| matches!(
31383-
unit.op,
31384-
Instruction::BuildList { .. }
31385-
| Instruction::ListAppend { .. }
31386-
| Instruction::CallIntrinsic1 { .. }
31387-
)));
31388-
assert!(code.constants.iter().any(|constant| matches!(
31389-
constant,
31390-
ConstantData::Tuple { elements } if elements.len() == 31
31391-
)));
31392-
}
31393-
3139431367
#[test]
3139531368
fn annotation_closure_uses_format_varname() {
3139631369
let code = compile_exec(

‎crates/codegen/src/ir.rs‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,13 +2227,14 @@ impl Blocks {
22272227
AnyInstruction::Real(Instruction::CallIntrinsic1 { func }) => {
22282228
match func.get(inst.arg) {
22292229
IntrinsicFunction1::ListToTuple => {
2230-
if !fold_constant_intrinsic_list_to_tuple(
2231-
metadata,
2232-
&mut self[block_idx],
2233-
i,
2234-
)? && matches!(nextop, Some(Instruction::GetIter))
2235-
{
2230+
if matches!(nextop, Some(Instruction::GetIter)) {
22362231
self[block_idx].instructions[i].set_to_nop();
2232+
} else {
2233+
fold_constant_intrinsic_list_to_tuple(
2234+
metadata,
2235+
&mut self[block_idx],
2236+
i,
2237+
)?;
22372238
}
22382239
}
22392240
IntrinsicFunction1::UnaryPositive => {

0 commit comments

Comments
 (0)