This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: mmap enhancement request
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.4
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, lambertv, ndbecker, pitrou, python-dev
Priority: low Keywords: easy, patch

Created on 2009-01-08 20:18 by ndbecker, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
issue-4885.patch lambertv, 2013-08-02 05:55 review
Messages (9)
msg79433 - (view) Author: (ndbecker) Date: 2009-01-08 20:18
I'd like to suggest some improvements from mmap

1) mmap assign to slice only accepts a string.  This is unfortunate,
because AFAIK a string can only be created by copying data, and this is
wasteful for large data transfers.  mmap should accept any object
supporting buffer protocol as well as string.

2) buffer (mmap_obj) gives a read_only buffer.  There should be a way to
make this read_write.  I suggest 'as_buffer' member.

3) mmap_obj does not support weak ref.  This is needed for proper
lifetime management using boost::python
msg79435 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-01-08 20:40
As for 2), the buffer() function is deprecated and is replaced in 3.0 by
new object called memoryview() (together with a revamped internal API
for taking and releasing buffers).
msg192658 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-08 15:18
1) and 2) have been fixed in Python 3.x. mmap supports writable memory views and slice assignment from any object that supports the buffer protocol.

3) is still an issue as mmap objects are not weakref-able yet. It should be easy to add __weakref__ to mmap objects.
msg192659 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-08 15:20
It's a trivial task for any Python developer with some C experience.
msg194156 - (view) Author: Valerie Lambert (lambertv) * Date: 2013-08-02 05:55
I've uploaded a patch to make mmap_obj support weakref. A test is included in the patch.
msg194176 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-08-02 14:33
Thanks Valerie. I've tested your patch and it looks good to me.
Have you signed and sent a contributor's agreement?
msg194215 - (view) Author: Valerie Lambert (lambertv) * Date: 2013-08-02 22:25
I just signed and sent the agreement electronically. Let me know if there is anything else I need to do.
msg194509 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-05 21:17
New changeset 1754b7900da1 by Antoine Pitrou in branch 'default':
Issue #4885: Add weakref support to mmap objects.  Patch by Valerie Lambert.
msg194510 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2013-08-05 21:18
Your patch is now committed. Thanks for contributing!
Date User Action Args
2022-04-11 14:56:43adminsetgithub: 49135
2013-08-05 21:18:13pitrousetstatus: open -> closed
resolution: fixed
messages: + msg194510

stage: patch review -> resolved
2013-08-05 21:17:43python-devsetnosy: + python-dev
messages: + msg194509
2013-08-02 22:25:41lambertvsetmessages: + msg194215
2013-08-02 14:33:55pitrousetmessages: + msg194176
2013-08-02 12:49:29pitrousetstage: needs patch -> patch review
2013-08-02 05:55:55lambertvsetfiles: + issue-4885.patch

nosy: + lambertv
messages: + msg194156

keywords: + patch
2013-07-08 15:20:37christian.heimessetkeywords: + easy

messages: + msg192659
2013-07-08 15:18:12christian.heimessetpriority: normal -> low

components: + Extension Modules, - Library (Lib)
versions: + Python 3.4, - Python 3.2
nosy: + christian.heimes

messages: + msg192658
stage: test needed -> needs patch
2010-08-09 03:13:05terry.reedysetstage: test needed
versions: + Python 3.2, - Python 3.1, Python 2.7
2009-01-08 20:40:11pitrousetpriority: normal
nosy: + pitrou
messages: + msg79435
versions: + Python 3.1, Python 2.7, - Python 2.5
2009-01-08 20:18:12ndbeckercreate