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
|
|
@ -693,13 +693,13 @@ public:
|
|||
* same package, otherwise load it as a global module.
|
||||
*/
|
||||
Printv(default_import_code, "# Import the low-level C/C++ module\n", NULL);
|
||||
Printv(default_import_code, "if __package__ or __name__.rpartition('.')[0]:\n", NULL);
|
||||
Printv(default_import_code, "if __package__ or '.' in __name__:\n", NULL);
|
||||
Printv(default_import_code, tab4, "from . import ", module, "\n", NULL);
|
||||
Printv(default_import_code, "else:\n", NULL);
|
||||
Printv(default_import_code, tab4, "import ", module, "\n", NULL);
|
||||
} else {
|
||||
Printv(default_import_code, "# Pull in all the attributes from the low-level C/C++ module\n", NULL);
|
||||
Printv(default_import_code, "if __package__ or __name__.rpartition('.')[0]:\n", NULL);
|
||||
Printv(default_import_code, "if __package__ or '.' in __name__:\n", NULL);
|
||||
Printv(default_import_code, tab4, "from .", module, " import *\n", NULL);
|
||||
Printv(default_import_code, "else:\n", NULL);
|
||||
Printv(default_import_code, tab4, "from ", module, " import *\n", NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue