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 — Add PyDict_ContainsString() · Issue #100100 · python/cpython

Add PyDict_ContainsString() #100100

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Add PyDict_ContainsString()#100100
Copy link
Labels
topic-C-APItype-featureA feature request or enhancementA feature request or enhancement

Description

@andrewhong04
andrewhong04
opened on Dec 8, 2022
Issue body actions

Feature or enhancement

I noticed that some functions like PyDict_GetItem(), PyDict_SetItem(), PyDict_DelItem(), etc has their variants that takes in a character array instead, but PyDict_Contains() does not.

Activity

  1. andrewhong04
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Dec 8, 2022
  2. sobolevn commented on Dec 8, 2022

    @sobolevn
    sobolevn
    on Dec 8, 2022
    Member
    More actions

    Adding things to CAPI would require to maintain this for many years: including tests / docs / etc. So, it needs a strong reasoning.

    What's your usecase for this? Can you go around your problem by using PyUnicode_FromString(your_string_key)?

  3. AlexWaygood
    added
    topic-C-API
    on Dec 8, 2022
  4. andrewhong04 commented on Dec 10, 2022

    @andrewhong04
    andrewhong04
    on Dec 10, 2022
    ContributorAuthor
    More actions

    I believe it should be added to add consistency and using PyUnicode_FromString(your_string_key) does work, but using PyDict_Contains(PyUnicode_FromString(your_string_key)) is a mouthful in my opinion.

  5. kumaraditya303 commented on Dec 10, 2022

    @kumaraditya303
    kumaraditya303
    on Dec 10, 2022
    Contributor
    More actions

    Just consistency is not a strong reason to add this. Note that PyDict_Contains is more efficient as you can cache the unicode object; PyDict_ContainsString would need to allocate a unicode object and throw it away after it is done.

  6. sobolevn
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Dec 10, 2022
  7. encukou commented on Dec 12, 2022

    @encukou
    encukou
    on Dec 12, 2022
    Member
    More actions

    Thank you for the suggestion. As said above, consistency alone isn't enough to add and maintain a new function. While C API has some shortcuts, this use case should be fine with PyUnicode_FromString+PyDict_Contains.
    I agree that it's a mouthful, but if you use it a lot, you can write your own helper function for it.

    Reacted by Andrew Hong
  8. encukou
    closed this as not plannedon Dec 12, 2022
  9. erlend-aasland
    removed
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-C-APItype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      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.