Skip to content

Conversation

@cdce8p
Copy link
Contributor

@cdce8p cdce8p commented Sep 15, 2025

Python/ceval.c Outdated
if (seen == NULL) {
return NULL;
PyObject *seen = NULL;
if (nattrs > 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
if (nattrs > 1) {
if (nargs > 1 || (nargs == 1 && nkwargs > 0)) {

As mentioned in #138912, I'd also like to change this. If there are only keyword arguments, it's easy to see if two are the same name. Furthermore linters are able to detect these based on the AST alone.

It would also be great to say if we could suggest users to prefer keyword arguments. Not only are they more explicit, they are also faster. (No lookup of __match_args__ and, with the change, no expensive duplicate name detection.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this in f585253 with if (nargs > 0 && nattrs > 1). I can revert it if necessary.

@eendebakpt
Copy link
Contributor

The CI failure seems unrelated. Updating the branch to rerun the CI just to be sure.

@cdce8p cdce8p force-pushed the match-class-performance branch from 359df88 to e0c2c1e Compare November 20, 2025 10:39
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.

4 participants