File tree Expand file tree Collapse file tree 2 files changed +0
-60
lines changed Expand file tree Collapse file tree 2 files changed +0
-60
lines changed Original file line number Diff line number Diff line change @@ -615,16 +615,6 @@ def check_same_constant(const):
615615 self .check_constant (f1 , Ellipsis )
616616 self .assertEqual (repr (f1 ()), repr (Ellipsis ))
617617
618- # Merge constants in tuple or frozenset
619- # NOTE: frozenset can't reuse previous const, but frozenset
620- # item can be reused later.
621- f3 = lambda x : x in {("not a name" ,)}
622- f1 , f2 = lambda : "not a name" , lambda : ("not a name" ,)
623- self .assertIs (next (iter (f3 .__code__ .co_consts [1 ])),
624- f2 .__code__ .co_consts [1 ])
625- self .assertIs (f1 .__code__ .co_consts [1 ],
626- f2 .__code__ .co_consts [1 ][0 ])
627-
628618 # {0} is converted to a constant frozenset({0}) by the peephole
629619 # optimizer
630620 f1 , f2 = lambda x : x in {0 }, lambda x : x in {0 }
Original file line number Diff line number Diff line change @@ -1240,56 +1240,6 @@ merge_consts_recursive(struct compiler *c, PyObject *o)
12401240 Py_DECREF (u );
12411241 }
12421242 }
1243- else if (PyFrozenSet_CheckExact (o )) {
1244- // We register items in the frozenset, but don't rewrite
1245- // the frozenset when the item is already registered
1246- // because frozenset is rare and difficult.
1247-
1248- // *key* is tuple. And it's first item is frozenset of
1249- // constant keys.
1250- // See _PyCode_ConstantKey() for detail.
1251- assert (PyTuple_CheckExact (key ));
1252- assert (PyTuple_GET_SIZE (key ) == 2 );
1253-
1254- Py_ssize_t len = PySet_GET_SIZE (o );
1255- if (len == 0 ) {
1256- return key ;
1257- }
1258- PyObject * tuple = PyTuple_New (len );
1259- if (tuple == NULL ) {
1260- Py_DECREF (key );
1261- return NULL ;
1262- }
1263- Py_ssize_t i = 0 , pos = 0 ;
1264- PyObject * item ;
1265- Py_hash_t hash ;
1266- while (_PySet_NextEntry (o , & pos , & item , & hash )) {
1267- PyObject * k = merge_consts_recursive (c , item );
1268- if (k == NULL ) {
1269- Py_DECREF (tuple );
1270- Py_DECREF (key );
1271- return NULL ;
1272- }
1273- PyObject * u ;
1274- if (PyTuple_CheckExact (k )) {
1275- u = PyTuple_GET_ITEM (k , 1 );
1276- }
1277- else {
1278- u = k ;
1279- }
1280- Py_INCREF (u );
1281- PyTuple_SET_ITEM (tuple , i , u );
1282- i ++ ;
1283- }
1284-
1285- PyObject * new = PyFrozenSet_New (tuple );
1286- Py_DECREF (tuple );
1287- if (new == NULL ) {
1288- Py_DECREF (key );
1289- return NULL ;
1290- }
1291- PyTuple_SET_ITEM (key , 1 , new );
1292- }
12931243
12941244 return key ;
12951245}
You can’t perform that action at this time.
0 commit comments