mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 10:26:02 +00:00 
			
		
		
		
	Use PyDict_Copy() and PyDict_Update() instead of using PyObject_CallMethod()
to call the corresponding methods. This is not a performance improvement since the times are still swamped by disk I/O, but cleans up the code just a little.
This commit is contained in:
		
							parent
							
								
									61f794918f
								
							
						
					
					
						commit
						9cd0efcee9
					
				
					 1 changed files with 3 additions and 5 deletions
				
			
		|  | @ -392,7 +392,7 @@ _PyImport_FixupExtension(char *name, char *filename) | ||||||
| 	dict = PyModule_GetDict(mod); | 	dict = PyModule_GetDict(mod); | ||||||
| 	if (dict == NULL) | 	if (dict == NULL) | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	copy = PyObject_CallMethod(dict, "copy", ""); | 	copy = PyDict_Copy(dict); | ||||||
| 	if (copy == NULL) | 	if (copy == NULL) | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	PyDict_SetItemString(extensions, filename, copy); | 	PyDict_SetItemString(extensions, filename, copy); | ||||||
|  | @ -403,7 +403,7 @@ _PyImport_FixupExtension(char *name, char *filename) | ||||||
| PyObject * | PyObject * | ||||||
| _PyImport_FindExtension(char *name, char *filename) | _PyImport_FindExtension(char *name, char *filename) | ||||||
| { | { | ||||||
| 	PyObject *dict, *mod, *mdict, *result; | 	PyObject *dict, *mod, *mdict; | ||||||
| 	if (extensions == NULL) | 	if (extensions == NULL) | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	dict = PyDict_GetItemString(extensions, filename); | 	dict = PyDict_GetItemString(extensions, filename); | ||||||
|  | @ -415,10 +415,8 @@ _PyImport_FindExtension(char *name, char *filename) | ||||||
| 	mdict = PyModule_GetDict(mod); | 	mdict = PyModule_GetDict(mod); | ||||||
| 	if (mdict == NULL) | 	if (mdict == NULL) | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	result = PyObject_CallMethod(mdict, "update", "O", dict); | 	if (PyDict_Update(mdict, dict)) | ||||||
| 	if (result == NULL) |  | ||||||
| 		return NULL; | 		return NULL; | ||||||
| 	Py_DECREF(result); |  | ||||||
| 	if (Py_VerboseFlag) | 	if (Py_VerboseFlag) | ||||||
| 		PySys_WriteStderr("import %s # previously loaded (%s)\n", | 		PySys_WriteStderr("import %s # previously loaded (%s)\n", | ||||||
| 			name, filename); | 			name, filename); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fred Drake
						Fred Drake