More Python module loading simplification
Slightly faster checking to see if a module is in a package. Issue #848
This commit is contained in:
parent
2a00d0f784
commit
355395200f
2 changed files with 4 additions and 4 deletions
|
|
@ -6282,7 +6282,7 @@ The code is generated into the pure Python module, foo.py, and merely imports th
|
|||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
if __package__ or __name__.rpartition('.')[0]:
|
||||
if __package__ or '.' in __name__:
|
||||
from . import _foo
|
||||
else:
|
||||
import _foo
|
||||
|
|
@ -6367,7 +6367,7 @@ The default import loading code is thus different:
|
|||
|
||||
<div class="targetlang">
|
||||
<pre>
|
||||
if __package__ or __name__.rpartition('.')[0]:
|
||||
if __package__ or '.' in __name__:
|
||||
from ._foo import *
|
||||
else:
|
||||
from _foo import *
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue