FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Provide `ctypes.memoryview_at()` · Issue #112015 · python/cpython · GitHub

Repository navigation

Provide ctypes.memoryview_at() #112015

Closed

Description

Feature or enhancement

Proposal:

It should be possible to easily make memoryview objects from pointer-able ctypes objects with an arbitrary length. In the same way we can currently use ctypes.string_at() to create bytes objects. The advantage of using memoryview objects is that we can elide a buffer copy.

import ctypes
a = (ctypes.c_ubyte * 10)()
ctypes.buffer_at(a, 10, True)[0] = 1
assert a[0] == 1
a[0] = 2
assert ctypes.buffer_at(a, 10, True)[0] == 2

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

Activity

  1. added
    stdlibStandard Library Python modules in the Lib/ directory
    on Nov 27, 2023
  2. rianhunter commented on Sep 19, 2024

    ContributorAuthor

    Abandoned

  3. ncoghlan commented on Sep 26, 2024

    Contributor

    @encukou is taking up work on the associated PR. Thanks for taking it this far @rianhunter!

  4. changed the title [-]Provide `ctypes.buffer_at()`[/-] [+]Provide `ctypes.memoryview_at()`[/+] on Sep 26, 2024
  5. added a commit that references this issue on Jan 3, 2025
  6. encukou commented on Jan 3, 2025

    Member

    And it's in!
    Thank you @rianhunter for the proposal and implementation, and all the reviewers for their insights.

  7. added a commit that references this issue on Jan 4, 2025
  8. added a commit that references this issue on Jan 8, 2025
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

    stdlibStandard Library Python modules in the Lib/ directorytopic-ctypestype-featureA feature request or enhancement

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL