@@ -532,29 +532,6 @@ fold_binop(expr_ty node, PyArena *arena, _PyASTOptimizeState *state)
532532    return  make_const (node , newval , arena );
533533}
534534
535- static  PyObject * 
536- make_const_tuple (asdl_expr_seq  * elts )
537- {
538-     for  (Py_ssize_t  i  =  0 ; i  <  asdl_seq_LEN (elts ); i ++ ) {
539-         expr_ty  e  =  (expr_ty )asdl_seq_GET (elts , i );
540-         if  (e -> kind  !=  Constant_kind ) {
541-             return  NULL ;
542-         }
543-     }
544- 
545-     PyObject  * newval  =  PyTuple_New (asdl_seq_LEN (elts ));
546-     if  (newval  ==  NULL ) {
547-         return  NULL ;
548-     }
549- 
550-     for  (Py_ssize_t  i  =  0 ; i  <  asdl_seq_LEN (elts ); i ++ ) {
551-         expr_ty  e  =  (expr_ty )asdl_seq_GET (elts , i );
552-         PyObject  * v  =  e -> v .Constant .value ;
553-         PyTuple_SET_ITEM (newval , i , Py_NewRef (v ));
554-     }
555-     return  newval ;
556- }
557- 
558535static  int 
559536fold_subscr (expr_ty  node , PyArena  * arena , _PyASTOptimizeState  * state )
560537{
@@ -574,54 +551,6 @@ fold_subscr(expr_ty node, PyArena *arena, _PyASTOptimizeState *state)
574551    return  make_const (node , newval , arena );
575552}
576553
577- /* Change literal list or set of constants into constant 
578-    tuple. Change literal list of non-constants into tuple. 
579-    Used for right operand of "in" and "not in" tests and for iterable 
580-    in "for" loop and comprehensions. 
581- */ 
582- static  int 
583- fold_iter (expr_ty  arg , PyArena  * arena , _PyASTOptimizeState  * state )
584- {
585-     PyObject  * newval ;
586-     if  (arg -> kind  ==  List_kind ) {
587-         /* First change a list into tuple. */ 
588-         asdl_expr_seq  * elts  =  arg -> v .List .elts ;
589-         if  (has_starred (elts )) {
590-             return  1 ;
591-         }
592-         expr_context_ty  ctx  =  arg -> v .List .ctx ;
593-         arg -> kind  =  Tuple_kind ;
594-         arg -> v .Tuple .elts  =  elts ;
595-         arg -> v .Tuple .ctx  =  ctx ;
596-         /* Try to create a constant tuple. */ 
597-         newval  =  make_const_tuple (elts );
598-     }
599-     else  {
600-         return  1 ;
601-     }
602-     return  make_const (arg , newval , arena );
603- }
604- 
605- static  int 
606- fold_compare (expr_ty  node , PyArena  * arena , _PyASTOptimizeState  * state )
607- {
608-     asdl_int_seq  * ops ;
609-     asdl_expr_seq  * args ;
610-     Py_ssize_t  i ;
611- 
612-     ops  =  node -> v .Compare .ops ;
613-     args  =  node -> v .Compare .comparators ;
614-     /* Change literal list or set in 'in' or 'not in' into tuple. */ 
615-     i  =  asdl_seq_LEN (ops ) -  1 ;
616-     int  op  =  asdl_seq_GET (ops , i );
617-     if  (op  ==  In  ||  op  ==  NotIn ) {
618-         if  (!fold_iter ((expr_ty )asdl_seq_GET (args , i ), arena , state )) {
619-             return  0 ;
620-         }
621-     }
622-     return  1 ;
623- }
624- 
625554static  int  astfold_mod (mod_ty  node_ , PyArena  * ctx_ , _PyASTOptimizeState  * state );
626555static  int  astfold_stmt (stmt_ty  node_ , PyArena  * ctx_ , _PyASTOptimizeState  * state );
627556static  int  astfold_expr (expr_ty  node_ , PyArena  * ctx_ , _PyASTOptimizeState  * state );
@@ -782,7 +711,6 @@ astfold_expr(expr_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
782711    case  Compare_kind :
783712        CALL (astfold_expr , expr_ty , node_ -> v .Compare .left );
784713        CALL_SEQ (astfold_expr , expr , node_ -> v .Compare .comparators );
785-         CALL (fold_compare , expr_ty , node_ );
786714        break ;
787715    case  Call_kind :
788716        CALL (astfold_expr , expr_ty , node_ -> v .Call .func );
@@ -852,7 +780,6 @@ astfold_comprehension(comprehension_ty node_, PyArena *ctx_, _PyASTOptimizeState
852780    CALL (astfold_expr , expr_ty , node_ -> iter );
853781    CALL_SEQ (astfold_expr , expr , node_ -> ifs );
854782
855-     CALL (fold_iter , expr_ty , node_ -> iter );
856783    return  1 ;
857784}
858785
@@ -939,8 +866,6 @@ astfold_stmt(stmt_ty node_, PyArena *ctx_, _PyASTOptimizeState *state)
939866        CALL (astfold_expr , expr_ty , node_ -> v .For .iter );
940867        CALL_SEQ (astfold_stmt , stmt , node_ -> v .For .body );
941868        CALL_SEQ (astfold_stmt , stmt , node_ -> v .For .orelse );
942- 
943-         CALL (fold_iter , expr_ty , node_ -> v .For .iter );
944869        break ;
945870    case  AsyncFor_kind :
946871        CALL (astfold_expr , expr_ty , node_ -> v .AsyncFor .target );
0 commit comments