@@ -542,53 +542,6 @@ fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
542542 return 1 ;
543543}
544544
545- /* Replace LOAD_CONST tuple with LOAD_CONST frozenset in the context
546- of a single-use constant for "in" and "not in" tests.
547- */
548- int
549- try_set_conversion (unsigned char * codestr , PyObject * consts )
550- {
551- PyObject * newconst , * constant ;
552- int arg , len_consts ;
553-
554- /* Pre-conditions */
555- assert (PyList_CheckExact (consts ));
556- assert (codestr [0 ] == LOAD_CONST );
557- assert (codestr [3 ] == COMPARE_OP );
558- assert (GETARG (codestr , 3 ) == 6 || GETARG (codestr , 3 ) == 7 );
559-
560- /* Attempt to convert constant to a frozenset. Bail-out with no
561- changes if the tuple contains unhashable values. */
562- arg = GETARG (codestr , 0 );
563- constant = PyList_GET_ITEM (consts , arg );
564- if (constant -> ob_type != & PyTuple_Type )
565- return 0 ;
566- newconst = PyObject_CallFunctionObjArgs (
567- (PyObject * )& PyFrozenSet_Type , constant , NULL );
568- if (newconst == NULL ) {
569- PyErr_Clear ();
570- return 0 ;
571- }
572-
573- /* Append new constant onto consts list or replace existing constant
574- if there are no other references to it.*/
575- if (constant -> ob_refcnt == 1 ) {
576- PyList_SET_ITEM (consts , arg , newconst );
577- Py_DECREF (constant );
578- return 1 ;
579- }
580- len_consts = PyList_GET_SIZE (consts );
581- if (PyList_Append (consts , newconst )) {
582- Py_DECREF (newconst );
583- return 0 ;
584- }
585- Py_DECREF (newconst );
586-
587- /* Write new LOAD_CONST newconst on top of LOAD_CONST oldconst */
588- SETARG (codestr , 0 , len_consts );
589- return 1 ;
590- }
591-
592545static unsigned int *
593546markblocks (unsigned char * code , int len )
594547{
@@ -714,15 +667,10 @@ optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *linen
714667 /* not a is b --> a is not b
715668 not a in b --> a not in b
716669 not a is not b --> a is b
717- not a not in b --> a in b
718-
719- a in c --> a in frozenset(c)
720- where c is a constant tuple of hashable values
670+ not a not in b --> a in b
721671 */
722672 case COMPARE_OP :
723673 j = GETARG (codestr , i );
724- if (lastlc >= 1 && (j == 6 || j == 7 ) && ISBASICBLOCK (blocks ,i - 3 ,6 ))
725- try_set_conversion (& codestr [i - 3 ], consts );
726674 if (j < 6 || j > 9 ||
727675 codestr [i + 3 ] != UNARY_NOT ||
728676 !ISBASICBLOCK (blocks ,i ,4 ))
0 commit comments