← 返回首页
bpo-1635741: Port symtable module to multiphase initialization by tiran · Pull Request #23361 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

bpo-1635741: Port symtable module to multiphase initialization#23361

Merged
miss-islington merged 2 commits into
python:masterfrom
tiran:bpo-1635741-symtable
Nov 18, 2020
Merged

bpo-1635741: Port symtable module to multiphase initialization#23361
miss-islington merged 2 commits into
python:masterfrom
tiran:bpo-1635741-symtable

Conversation

tiran commented Nov 18, 2020
edited by miss-islington
Loading

Copy link
Copy Markdown
Member

Signed-off-by: Christian Heimes christian@python.org

https://bugs.python.org/issue1635741

Automerge-Triggered-By: GH:tiran

Signed-off-by: Christian Heimes <christian@python.org>
tiran changed the title Port symtable module to multiphase initialization bpo-1635741: Port symtable module to multiphase initialization Nov 18, 2020
tiran force-pushed the bpo-1635741-symtable branch from ee17c63 to bb7961b Compare November 18, 2020 09:55
Comment thread Modules/symtablemodule.c
static int
symtable_init_stentry_type(PyObject *m)
{
return PyType_Ready(&PySTEntry_Type);

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

I don't see the value of having two exec slots. Why not simply putting all exec code into a single function?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

They do different things. Also PySTEntry_Type is define somewhere else and we might want to move the type initialization when the PySTEntry_Type is refactored.

Comment thread Modules/symtablemodule.c Outdated Show resolved Hide resolved
Comment thread Modules/symtablemodule.c

static int
symtable_init_constants(PyObject *m)
{

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

I'm trying to slowly use macros to factorize the code, something like:

#define ADD_INT(value) \ if (PyModule_AddIntConstant(module, #value, value) < 0) { \ return -1; \ }

A more generic machinery like the one you proposed would avoid such macro, and until there is such API, IMO using a macro makes the code more readable:

ADD_INT(USE);

You can add a second macro for PyModule_AddIntConstant() calls.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

I'd rather not spend more time then necessary. This was a simple search and replace job.

Let's consider refactoring after PyModuleConstants_Def from #23286 has landed. The new feature will make module constant definitions easier.

vstinner left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality Hide comment

LGTM.

miss-islington merged commit c701101 into python:master Nov 18, 2020
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
…nGH-23361) Signed-off-by: Christian Heimes <christian@python.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Footer

© 2026 GitHub, Inc.