Skip to content

Docs: reword the dbm.dumb introduction #114550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 26, 2024

Conversation

erlend-aasland
Copy link
Contributor

@erlend-aasland erlend-aasland commented Jan 25, 2024

Also:

  • consistently use correct parameter markup
  • consistently use submodule name as database name
  • improve accuracy of the dbm.dumb.open() spec
  • remove dumbdbm class refs and replace them with generic "database object"
  • use parameter list for dbm.dumb.open()

📚 Documentation preview 📚: https://cpython-previews--114550.org.readthedocs.build/

Also:

- consistently name the database "dumbdbm"
- fix broken dumbdbm class refs
- improve accuracy of the dbm.dump.open() spec
Co-authored-by: Ezio Melotti <[email protected]>
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

I noticed it yesterday and was going to replace all "dumbdbm" with "dbm.dumb". "dumbdbm" is the name of the module in Python 2. Now it is "dbm.dumb".

@erlend-aasland
Copy link
Contributor Author

I noticed it yesterday and was going to replace all "dumbdbm" with "dbm.dumb". "dumbdbm" is the name of the module in Python 2. Now it is "dbm.dumb".

Notice that for each backend, there are three names to keep in mind:

  • the name of the module, for example dbm.dumb and dbm.gnu
  • the name of the database manager, for example "dumbdbm" and GDBM
  • the name of the class, for example dbm.gnu.gdbm and dbm.dumb._Database

This PR aligns the name of the database manager and the name of the class. Note that I deliberately did not use the _Database name as the class name. Instead I simply made the markup consistent and used dumbdbm. What I've done in the dbm.sqlite3 PR, is to deliberatly not mention the class name. Perhaps we can do that in other places of the dbm docs as well.

@erlend-aasland
Copy link
Contributor Author

Let me expand on #114550 (comment): the docs already use dumbdbm as the class name; this PR only removes the broken reference.

@serhiy-storchaka
Copy link
Member

ndbm and gdbm refer to external libraries and formats. Dumbdbm does not exist outside of the context of the dbm.dumb module, so why use name "dumbdbm" instead of "dbm.dumb" which directly refers to the module name?

I planned to replace "a dumbdbm object" with simple "a database object", since the name of the class is not public.

@erlend-aasland
Copy link
Contributor Author

ndbm and gdbm refer to external libraries and formats. Dumbdbm does not exist outside of the context of the dbm.dumb module, so why use name "dumbdbm" instead of "dbm.dumb" which directly refers to the module name?

Because there is different wording depending on if you talk about a type of database or a module. If we chose to not talk about the database type ("dumbdbm"), then we have to adjust the wording even more. I can do that, since you insist.

I planned to replace "a dumbdbm object" with simple "a database object", since the name of the class is not public.

This is what I did for the dbm.sqlite3 PR. We can do the same here.

@erlend-aasland erlend-aasland marked this pull request as draft January 26, 2024 11:12
- Don't use "dumbdbm" as a database name; instead use the submodule name

- Don't use a class name; only talk about "database objects"

- Consistently use correct markup for parameters

- Use param list for open()
@erlend-aasland erlend-aasland marked this pull request as ready for review January 26, 2024 11:40
@erlend-aasland
Copy link
Contributor Author

I tried to address all your concerns in 4445822 @serhiy-storchaka.


The optional *flag* argument can be:
:param filename:
The basename of the database file (without extensions).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO, "without extensions" is to be understood by the term "basename". The following should suffice:

Suggested change
The basename of the database file (without extensions).
The basename of the database file.

Comment on lines +353 to +354
As with other :mod:`dbm` backends,
the keys and values are always stored as :class:`bytes`.
Copy link
Member

Choose a reason for hiding this comment

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

This note looks strange now.

In Python 2, str and unicode was interchangeable to some degree. If you use ASCII-only, it was not important that you set db['key'] = 'value' or db[u'key'] = u'value'. But it may still be useful to know that if you set an unicode value, you get back a str value. This is what about this note. It is not about the internal format, it is about the output types.

But in Python 3 bytes and str are no longer interchangeable, they are no longer different representations of the same. So this is more serious question. The database is bytes to bytes mapping by its nature, but it accepts also str as input and automatically encode them to bytes using UTF-8. This should be true for all dbm implementations, so perhaps this explanation should be move to more generic description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This note looks strange now.

You prefer the old variant? "As with other persistent mappings, the keys and values are always stored as bytes."

This should be true for all dbm implementations, so perhaps this explanation should be move to more generic description.

This is already mentioned in the generic description. It is also mentioned in the docs of every dbm submodule. If we want to address this, we should do so in a separate PR; this PR is for dbm.dumb docs only.

It is tempting to grow the scope of doc PR, and end up changing a lot of things at once. This makes for complicated docs changes where it is hard to see what changes were actually done. I prefer if we try to focus on atomic doc changes.

Copy link
Member

Choose a reason for hiding this comment

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

I just noticed that it looks strange (both old and new variants). It could be improved in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created #114609 to follow up this.

@erlend-aasland erlend-aasland merged commit 6c2b419 into python:main Jan 26, 2024
@erlend-aasland erlend-aasland deleted the docs/dbmdumb/reword branch January 26, 2024 18:12
@miss-islington-app

This comment has been minimized.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 26, 2024
- consistently use correct parameter markup
- consistently use submodule name as database name
- improve accuracy of the dbm.dumb.open() spec
- remove dumbdbm class refs and replace them with generic "database object"
- use parameter list for dbm.dumb.open()
(cherry picked from commit 6c2b419)

Co-authored-by: Erlend E. Aasland <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 26, 2024
- consistently use correct parameter markup
- consistently use submodule name as database name
- improve accuracy of the dbm.dumb.open() spec
- remove dumbdbm class refs and replace them with generic "database object"
- use parameter list for dbm.dumb.open()
(cherry picked from commit 6c2b419)

Co-authored-by: Erlend E. Aasland <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jan 26, 2024

GH-114620 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Jan 26, 2024
@bedevere-app
Copy link

bedevere-app bot commented Jan 26, 2024

GH-114621 is a backport of this pull request to the 3.11 branch.

@erlend-aasland
Copy link
Contributor Author

Thanks for the reviews, everyone.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Jan 26, 2024
erlend-aasland added a commit that referenced this pull request Jan 26, 2024
(cherry picked from commit 6c2b419)

- consistently use correct parameter markup
- consistently use submodule name as database name
- improve accuracy of the dbm.dumb.open() spec
- remove dumbdbm class refs and replace them with generic "database object"
- use parameter list for dbm.dumb.open()
(cherry picked from commit 6c2b419)

Co-authored-by: Erlend E. Aasland <[email protected]>
erlend-aasland added a commit that referenced this pull request Jan 26, 2024
(cherry picked from commit 6c2b419)

- consistently use correct parameter markup
- consistently use submodule name as database name
- improve accuracy of the dbm.dumb.open() spec
- remove dumbdbm class refs and replace them with generic "database object"
- use parameter list for dbm.dumb.open()
(cherry picked from commit 6c2b419)

Co-authored-by: Erlend E. Aasland <[email protected]>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
- consistently use correct parameter markup
- consistently use submodule name as database name
- improve accuracy of the dbm.dumb.open() spec
- remove dumbdbm class refs and replace them with generic "database object"
- use parameter list for dbm.dumb.open()
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
- consistently use correct parameter markup
- consistently use submodule name as database name
- improve accuracy of the dbm.dumb.open() spec
- remove dumbdbm class refs and replace them with generic "database object"
- use parameter list for dbm.dumb.open()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants