mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	Issue #14383: Add _PyDict_GetItemId() and _PyDict_SetItemId() functions
These functions simplify the usage of static constant Unicode strings. Generalize the usage of _Py_Identifier in ceval.c and typeobject.c.
This commit is contained in:
		
							parent
							
								
									70b2e1e7d9
								
							
						
					
					
						commit
						3c1e48176e
					
				
					 4 changed files with 118 additions and 122 deletions
				
			
		| 
						 | 
				
			
			@ -822,6 +822,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 | 
			
		|||
    PyObject *names;
 | 
			
		||||
    PyObject *consts;
 | 
			
		||||
 | 
			
		||||
    _Py_IDENTIFIER(__ltrace__);
 | 
			
		||||
 | 
			
		||||
/* Computed GOTOs, or
 | 
			
		||||
       the-optimization-commonly-but-improperly-known-as-"threaded code"
 | 
			
		||||
   using gcc's labels-as-values extension
 | 
			
		||||
| 
						 | 
				
			
			@ -1198,7 +1200,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
#ifdef LLTRACE
 | 
			
		||||
    lltrace = PyDict_GetItemString(f->f_globals, "__lltrace__") != NULL;
 | 
			
		||||
    lltrace = _PyDict_GetItemId(f->f_globals, &PyId___ltrace__) != NULL;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    why = WHY_NOT;
 | 
			
		||||
| 
						 | 
				
			
			@ -1926,8 +1928,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 | 
			
		|||
            break;
 | 
			
		||||
 | 
			
		||||
        TARGET(LOAD_BUILD_CLASS)
 | 
			
		||||
            x = PyDict_GetItemString(f->f_builtins,
 | 
			
		||||
                                     "__build_class__");
 | 
			
		||||
        {
 | 
			
		||||
            _Py_IDENTIFIER(__build_class__);
 | 
			
		||||
            x = _PyDict_GetItemId(f->f_builtins, &PyId___build_class__);
 | 
			
		||||
            if (x == NULL) {
 | 
			
		||||
                PyErr_SetString(PyExc_ImportError,
 | 
			
		||||
                                "__build_class__ not found");
 | 
			
		||||
| 
						 | 
				
			
			@ -1936,6 +1939,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 | 
			
		|||
            Py_INCREF(x);
 | 
			
		||||
            PUSH(x);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        TARGET(STORE_NAME)
 | 
			
		||||
            w = GETITEM(names, oparg);
 | 
			
		||||
| 
						 | 
				
			
			@ -2283,8 +2287,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 | 
			
		|||
            DISPATCH();
 | 
			
		||||
 | 
			
		||||
        TARGET(IMPORT_NAME)
 | 
			
		||||
        {
 | 
			
		||||
            _Py_IDENTIFIER(__import__);
 | 
			
		||||
            w = GETITEM(names, oparg);
 | 
			
		||||
            x = PyDict_GetItemString(f->f_builtins, "__import__");
 | 
			
		||||
            x = _PyDict_GetItemId(f->f_builtins, &PyId___import__);
 | 
			
		||||
            if (x == NULL) {
 | 
			
		||||
                PyErr_SetString(PyExc_ImportError,
 | 
			
		||||
                                "__import__ not found");
 | 
			
		||||
| 
						 | 
				
			
			@ -2325,6 +2331,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 | 
			
		|||
            SET_TOP(x);
 | 
			
		||||
            if (x != NULL) DISPATCH();
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        TARGET(IMPORT_STAR)
 | 
			
		||||
            v = POP();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue