Skip to content

Implement PyObject_CopyToObject #84016

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

Closed
nanjekyejoannah opened this issue Mar 3, 2020 · 3 comments
Closed

Implement PyObject_CopyToObject #84016

nanjekyejoannah opened this issue Mar 3, 2020 · 3 comments
Labels
3.9 only security fixes topic-C-API type-feature A feature request or enhancement

Comments

@nanjekyejoannah
Copy link
Contributor

nanjekyejoannah commented Mar 3, 2020

BPO 39835
Nosy @nanjekyejoannah

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2020-03-03.15:18:33.166>
labels = ['expert-C-API', 'type-feature', '3.9']
title = 'Implement PyObject_CopyToObject'
updated_at = <Date 2020-03-03.15:18:33.166>
user = 'https://github.com/nanjekyejoannah'

bugs.python.org fields:

activity = <Date 2020-03-03.15:18:33.166>
actor = 'nanjekyejoannah'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['C API']
creation = <Date 2020-03-03.15:18:33.166>
creator = 'nanjekyejoannah'
dependencies = []
files = []
hgrepos = []
issue_num = 39835
keywords = []
message_count = 1.0
messages = ['363264']
nosy_count = 1.0
nosy_names = ['nanjekyejoannah']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue39835'
versions = ['Python 3.9']

Linked PRs

@nanjekyejoannah
Copy link
Contributor Author

I suggest implementing a C-API for copying data into a buffer exported by an obj. i.e

int PyObject_CopyToObject(PyObject *obj, void *buf, Py_ssize_t len,
                          char fortran)

as was intended in PEP-3118. The documentation there says this functionality should:

"Copy len bytes of data pointed to by the contiguous chunk of memory pointed to by buf into the buffer exported by obj. Return 0 on success and return -1 and raise an error on failure. If the object does not have a writable buffer, then an error is raised. If fortran is 'F', then if the object is multi-dimensional, then the data will be copied into the array in Fortran-style (first dimension varies the fastest). If fortran is 'C', then the data will be copied into the array in C-style (last dimension varies the fastest). If fortran is 'A', then it does not matter and the copy will be made in whatever way is more efficient."

@nanjekyejoannah nanjekyejoannah added 3.9 only security fixes topic-C-API type-feature A feature request or enhancement labels Mar 3, 2020
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@JelleZijlstra
Copy link
Member

PEP-3118 was written 18 years ago and we've managed without this function for that long. I think we should add it only if there are clear use cases, not simply because it's in the PEP.

If you'd like this function implemented, could you provide examples of existing code (e.g., in existing C extensions) that would be made better by this function?

@vstinner
Copy link
Member

I just close the issue. If someone wants to reopen the issue, please come with convincing examples. Not just a reference to an old PEP.

@erlend-aasland erlend-aasland closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.9 only security fixes topic-C-API type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants