Skip to content

Refactor PyImport_ImportModuleLevelObject().#4680

Merged
nascheme merged 2 commits intopython:masterfrom
nascheme:import_find_and_load
Dec 3, 2017
Merged

Refactor PyImport_ImportModuleLevelObject().#4680
nascheme merged 2 commits intopython:masterfrom
nascheme:import_find_and_load

Conversation

@nascheme
Copy link
Copy Markdown
Member

@nascheme nascheme commented Dec 2, 2017

Add import_find_and_load() helper function. The addition of
the importtime option has made PyImport_ImportModuleLevelObject() large
and so using a helper seems worthwhile. It also makes it clearer that
abs_name is the only argument needed by _find_and_load().

Add import_find_and_load() helper function.  The addition of
the importtime option has made PyImport_ImportModuleLevelObject() large
and so using a helper seems worthwhile.  It also makes it clearer that
abs_name is the only argument needed by _find_and_load().
@nascheme nascheme force-pushed the import_find_and_load branch from 3e15686 to 864202a Compare December 2, 2017 21:27
Comment thread Python/import.c
mod = import_find_and_load(abs_name);
if (mod == NULL)
goto error;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove braces when existing code use braces.

https://www.python.org/dev/peps/pep-0007/

Code structure: one space between keywords like if, for and the following left paren; no spaces inside the paren; braces are required everywhere, even where C permits them to be omitted, but do not add them to code you are not otherwise modifying. All new C code requires braces.

Copy link
Copy Markdown
Member

@methane methane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside from the minor brace formatting issue @methane mentioned, this looks good to me.

@nascheme nascheme merged commit eea3cc1 into python:master Dec 3, 2017
Comment thread Python/import.c
mod != NULL);

if (import_time) {
_PyTime_t cum = _PyTime_GetPerfCounter() - t1;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see .. a cultured individual .. good job 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants