A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039724.html below:

[Python-Dev] RE: cloning iterators again

[Python-Dev] RE: cloning iterators againGuido van Rossum guido at python.org
Tue Oct 28 13:34:09 EST 2003
> Ok on this point, the question was whether (the error-checking obfuscated
> equivalent of)
> 
>    PyObject *m = PyImport_ImportModule("copy");
>    PyObject_CallMethod(m, "deepcopy", x, memo);
> 
> should be done inside a built-in __deepcopy__ implementation.  It looks like
> it will make a hell of a lot of quite slow calls to PyImport_ImportModule()  
> for structures like lists of generators, which is the kind of structure you
> are interested in when you deepcopy generators.

Yeah, you should ideally be able to cache the resuls of the import,
except then your code wouldn't work when theer are multiple
interpreters.  Maybe using

  PyObject *modules = PySys_GetObject("modules");
  PyObject *m = PyDict_Lookup(modules, "copy");

would be faster?  PySys_GetObject() doesn't waste much time. :-)

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4