GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-46006: Fix _PyUnicode_EqualToASCIIId() for interned strings by vstinner · Pull Request #30123 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Dec 15, 2021 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fix string comparisons for subinterpreters: no longer make the assumption
that two interned strings are not equal if they have different different
memory addresses. This assumption is no longer true since interned
strings have been made per interpreter in Python 3.10.

Fix _PyUnicode_EqualToASCIIId() and type update_slot() functions.

The change makes update_slot() a little bit less efficient:
update_slot() now compares the strings contents, rather than
comparing strings memory addresses.

https://bugs.python.org/issue46006

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner
bpo-46006: Fix _PyUnicode_EqualToASCIIId() for interned strings
41c1f59
Fix string comparisons for subinterpreters: no longer make the assumption
that two interned strings are not equal if they have different different
memory addresses. This assumption is no longer true since interned
strings have been made per interpreter in Python 3.10.

Fix _PyUnicode_EqualToASCIIId() and type update_slot() functions.

The change makes update_slot() a little bit less efficient:
update_slot() now compares the strings contents, rather than
comparing strings memory addresses.
@vstinner vstinner added the needs backport to 3.10 label Dec 15, 2021
@vstinner
vstinner requested a review from markshannon as a code owner December 15, 2021 14:44
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Dec 15, 2021
@bedevere-bot bedevere-bot added the awaiting core review label Dec 15, 2021
@vstinner

vstinner commented Dec 15, 2021

Copy link
Copy Markdown
Member Author

cc @methane @serhiy-storchaka @corona10

We will be able to add again this micro-optimization once Python C extensions and third-party C extensions will no longer define and use static types and will stop sharing objects between two interpreters. Sadly, this long term goal may take a few years...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Dec 15, 2021

Copy link
Copy Markdown
Member

It is meaningless to compare strings from one fully isolated interpreter with those in another.
So the assumption that id(o1) != id(o2) implies o1 != o2 is still true for a valid comparison of interned strings.

Feel free to add an assert, but please avoid this sort of pessimization for a hypothetical future which may well not happen.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hroncok

hroncok commented Dec 15, 2021

Copy link
Copy Markdown
Contributor

Suggestion: add the reproducer from https://bugs.python.org/issue46034 as a test?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Dec 15, 2021

Copy link
Copy Markdown
Member Author

Feel free to add an assert, but please avoid this sort of pessimization for a hypothetical future which may well not happen.

@markshannon: I'm not sure what you are talking about. https://bugs.python.org/issue46006 is affecting multiple Python 3.10 users right now. It's not an hypothetical bug. At least, jep and mod_wsgi projects are known to be affected by the bug:

  • SubIntepreters don't work with DontWriteBytecodeFlag in Python 3.10 ninia/jep#358
  • Decorators on classes ignored GrahamDumpleton/mod_wsgi#729
  • (Py3.10) Error on loading: TypeError: TypeChecker() takes no arguments  poljar/weechat-matrix#293
  • https://bugzilla.redhat.com/show_bug.cgi?id=2030621
  • etc.

The bug may also explain https://bugs.python.org/issue46070 which affects more projects.

foxyseta reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Dec 15, 2021

Copy link
Copy Markdown
Member Author

It is meaningless to compare strings from one fully isolated interpreter with those in another.

@markshannon: I added long comments as part of the change to explain the issue. Did you see my comments? It's about interned strings of static types which are shared by all interpreters.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Dec 15, 2021

Copy link
Copy Markdown
Member

I'll comment on the issue.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Dec 15, 2021

Copy link
Copy Markdown
Member

I agree that a fix is needed. But this is not the needed fix.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Jan 6, 2022

Copy link
Copy Markdown
Member Author

I merged GH-20085 instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner closed this Jan 6, 2022
@vstinner
vstinner deleted the interned branch January 6, 2022 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon Awaiting requested review from markshannon markshannon is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting core review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@vstinner @markshannon @hroncok @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.