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-46541: Replace _Py_IDENTIFIER with _Py_ID in sqlite3 by erlend-aasland · Pull Request #31351 · python/cpython

Conversation

@erlend-aasland

@erlend-aasland erlend-aasland commented Feb 15, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

https://bugs.python.org/issue46541

Sorry, something went wrong.

Uh oh!

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

All reactions
@erlend-aasland
erlend-aasland requested a review from berkerpeksag as a code owner February 15, 2022 09:37
@bedevere-bot bedevere-bot added the awaiting review label Feb 15, 2022
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Feb 15, 2022
@erlend-aasland
erlend-aasland requested a review from ericsnowcurrently February 15, 2022 09:37
@erlend-aasland erlend-aasland added the skip news label Feb 15, 2022
@erlend-aasland

erlend-aasland commented Feb 15, 2022

Copy link
Copy Markdown
Contributor Author

Assuming we skip news, since this is an internal change only.

All reactions

Sorry, something went wrong.

Uh oh!

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

Erlend E. Aasland added 3 commits February 15, 2022 10:45
Erlend E. Aasland
Use _Py_ID in sqlite3
004d092
Erlend E. Aasland
Only include Python.h in module.h
841a72a
Erlend E. Aasland
Regen global objects
339d1f7
@erlend-aasland
erlend-aasland force-pushed the sqlite-pyid branch from 3a66af2 to 339d1f7 Compare February 15, 2022 09:45
Erlend E. Aasland
Revert unneeded changes
dddc95a
@ericsnowcurrently

ericsnowcurrently commented Feb 15, 2022

Copy link
Copy Markdown
Member

The main reason I didn't do this earlier is because our (non-builtin) extension modules probably shouldn't be relying on internal API. Instead we should try to use only public API (and sometimes "private", AKA public API with a leading underscore).

How bad would it be to replace uses of _Py_IDENTIFIER() with PyUnicode_InternFromString()?

erlend-aasland 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.

@ericsnowcurrently ericsnowcurrently mentioned this pull request Feb 15, 2022
bpo-46541: Remove usage of _Py_IDENTIFIER from dbms modules #31358
Merged
@erlend-aasland

erlend-aasland commented Feb 15, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

The main reason I didn't do this earlier is because our (non-builtin) extension modules probably shouldn't be relying on internal API.

It's fully possible to build any stdlib extension as a built-in, even sqlite3.

How bad would it be to replace uses of _Py_IDENTIFIER() with PyUnicode_InternFromString()?

Most users will call execute and friend on a cursor object, not on a connection object, so they won't notice neither performance improvements nor regressions. I'm not sure about the adapter case though; I don't know how widely used they actually are.

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Feb 15, 2022

Copy link
Copy Markdown
Contributor Author

The main reason I didn't do this earlier is because our (non-builtin) extension modules probably shouldn't be relying on internal API. Instead we should try to use only public API (and sometimes "private", AKA public API with a leading underscore).

OTOH, I'm totally fine with mainly using public APIs in the sqlite3 module. I'll rewrite it to use public APIs instead.

ericsnowcurrently 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.

Erlend E. Aasland added 2 commits February 15, 2022 20:55
Erlend E. Aasland
Revert "Only include Python.h in module.h"
fd32155
This reverts commit 841a72a.
Erlend E. Aasland
Revert "Regen global objects"
ac8c3db
This reverts commit 339d1f7.
@ericsnowcurrently

ericsnowcurrently commented Feb 15, 2022

Copy link
Copy Markdown
Member

BTW, thanks for working on this!

erlend-aasland reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland

erlend-aasland commented Feb 15, 2022

Copy link
Copy Markdown
Contributor Author

BTW, thanks for working on this!

Likewise :)

All reactions

Sorry, something went wrong.

Uh oh!

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

Erlend E. Aasland
Use interned strings
843d19a
@erlend-aasland

erlend-aasland commented Feb 16, 2022 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor Author

PTAL. This should result in a small speedup compared to main.

The sqlite3.Connection.cursor() calls are now made directly. Ideally we should do the same with the Cursor.execute* calls, but sqlite3 is inconveniently implemented across multiple files1, so we can't just call the cursor impl methods directly. I changed the scope of _pysqlite_query_execute, so we can at least speed up the Connection.execute() and Connection.executemany() calls. The remaining methods now use interned strings, with the module always keeping a strong ref to __adapt__, __conform__, and upper to speed up adapters/converters, and finalize to speed up user-defined functions. I did the same for executemany; it is probably not used in hot code, but following the same pattern simplified the code a bit.

Footnotes

  1. Consolidating all the Module/_sqlite/*.[ch] files into Module/_sqlite3.[ch] would be very helpful. ↩

All reactions

Sorry, something went wrong.

Uh oh!

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

Erlend E. Aasland
Call execute/executemany directly
b2d945a
@erlend-aasland
erlend-aasland requested a review from corona10 February 16, 2022 10:24
corona10
corona10 approved these changes Feb 16, 2022
View reviewed changes

@corona10 corona10 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

lgtm

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting review labels Feb 16, 2022
@corona10
corona10 merged commit b207711 into python:main Feb 16, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Feb 16, 2022
@erlend-aasland
erlend-aasland deleted the sqlite-pyid branch February 16, 2022 16:49
@erlend-aasland

erlend-aasland commented Feb 16, 2022

Copy link
Copy Markdown
Contributor Author

Thanks for your review and thoughts, @corona10 & @ericsnowcurrently

All reactions

Sorry, something went wrong.

Uh oh!

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

@erlend-aasland erlend-aasland mentioned this pull request Feb 17, 2022
bpo-46634: Inline calls to Connection.cursor() in sqlite3 #31127
Closed
@ericsnowcurrently ericsnowcurrently mentioned this pull request Jul 9, 2022
Replace _Py_IDENTIFIER() with statically initialized objects. #90699
Closed
@erlend-aasland erlend-aasland mentioned this pull request Jun 27, 2023
gh-106104: Use public weakref APIs in sqlite3 #106105
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@corona10 corona10 corona10 approved these changes
@berkerpeksag berkerpeksag Awaiting requested review from berkerpeksag
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently

Uh oh!

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

Assignees

No one assigned

Labels

skip news

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

@erlend-aasland @ericsnowcurrently @corona10 @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 01402503 — 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.