Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] requirements for moving __import__ over toimportlib?

Brett Cannonbrett at python.org
Wed Feb 8 17:24:58 CET 2012


On Wed, Feb 8, 2012 at 11:09, Antoine Pitrou <solipsis at pitrou.net> wrote:> Le mercredi 08 février 2012 à 11:01 -0500, Brett Cannon a écrit :> >> >> > On Tue, Feb 7, 2012 at 17:42, Antoine Pitrou <solipsis at pitrou.net>> > wrote:> >         On Tue, 7 Feb 2012 17:24:21 -0500> >         Brett Cannon <brett at python.org> wrote:> >         >> >         > IOW you want the sys.modules case fast, which I will never> >         be able to match> >         > compared to C code since that is pure execution with no I/O.> >> >> >         Why wouldn't continue using C code for that? It's trivial> >         (just a dict> >         lookup).> >> >> >  Sure, but it's all the code between the function call and hitting> > sys.modules which would also need to get shoved into the C code. As I> > said, I have not tried to optimize anything yet (and unfortunately a> > lot of the upfront costs are over stupid things like checking if> > __import__ is being called with a string for the module name).>> I guess my point was: why is there a function call in that case? The> "import" statement could look up sys.modules directly.>Because people like to do wacky stuff  with their imports and so fullybypassing __import__ would be bad.> Or the built-in __import__ could still be written in C, and only defer> to importlib when the module isn't found in sys.modules.> Practicality beats purity. It's a possibility, although that would require every function call tofetch the PyInterpreterState to get at the cached __import__ (so the propersys and imp modules are used) and I don't know how expensive that would be(probably as not as expensive as calling out to Python code but I'mthinking out loud).-------------- next part --------------An HTML attachment was scrubbed...URL: <http://mail.python.org/pipermail/python-dev/attachments/20120208/c459b1d9/attachment-0001.html>


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp