Issue1967
Created on 2008-01-29 22:39 by twouters, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| dictviews_backport.diff | twouters, 2008-01-31 01:50 | |||
| backport_dictviews.diff | alexandre.vassalotti, 2009-08-04 23:51 | |||
| 2to3_fixer_dictviews.diff | alexandre.vassalotti, 2009-08-04 23:53 | |||
| backport_dictviews-2.diff | alexandre.vassalotti, 2009-12-30 23:09 | |||
| backport_dictviews-3.diff | alexandre.vassalotti, 2009-12-30 23:39 | |||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 15143 | closed | python-dev, 2019-08-06 13:24 | |
| Messages (11) | |||
|---|---|---|---|
| msg61834 - (view) | Author: Thomas Wouters (twouters) * ![]() |
Date: 2008-01-29 22:39 | |
Patch to backport dictviews to trunk. Consists of some trickery: - new 'viewkeys', 'viewvalues' and 'viewitems' methods of dicts, returning exactly what 'keys', 'values' and 'items' return in 3.0: three new types defined in dictobject.c - a future import (dictviews) that changes which opcodes are generated for (some) attribute access - special opcodes for getting and setting 'keys', 'values' and 'items' attributes from an object. These opcodes do nothing special unless a future import is in effect in the calling code block *and* the type they are called on is a dict subclass, in which case they translate 'keys', 'values' and 'items' to 'viewkeys', 'viewvalues' and 'viewitems'. - similar specialcasing in getattr() and setattr() |
|||
| msg61881 - (view) | Author: Thomas Wouters (twouters) * ![]() |
Date: 2008-01-31 01:50 | |
After talking to Guido, got rid of the future import magic in favour of just providing 'viewkeys', 'viewitems' and 'viewvalues' methods of dicts. This makes efficient 2.6-and-3.0 dict-using code possibly by making 2to3 translate the view-methods directly to keys/values/items in 3.0, and not wrapping everything in list(). |
|||
| msg70359 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2008-07-28 17:02 | |
I'm going to defer this to 2.7. |
|||
| msg91285 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * ![]() |
Date: 2009-08-04 23:51 | |
I have refreshed Thomas's patch to reflect recent updates to dictviews. I also added the documentation for dictviews. |
|||
| msg91286 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * ![]() |
Date: 2009-08-04 23:53 | |
Here is a patch for 2to3 to support the translation of code using dictviews. |
|||
| msg96258 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * ![]() |
Date: 2009-12-11 14:17 | |
Can someone review the patches? I would like to commit this later this week. |
|||
| msg96276 - (view) | Author: Ezio Melotti (ezio.melotti) * ![]() |
Date: 2009-12-11 22:59 | |
The patch (backport_dictviews.diff) doesn't seem to work for me. I
applied it on trunk after a svn up, did "./configure && make" and when I
tried d.view{items|keys|values} Python segfaulted:
Python 2.7a1+ (trunk:76759M, Dec 12 2009, 00:28:52)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> d = dict(a=3, b=5)
>>> d.viewitems()
Segmentation fault
I'm tested it on Ubuntu 9.10.
The docstrings of the three methods are also wrong:
+PyDoc_STRVAR(viewkeys__doc__,
+ "D.keys() -> a set-like object providing a view on D's keys");
This should be "D.viewkeys() -> ...", same with the other two.
|
|||
| msg97066 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * ![]() |
Date: 2009-12-30 23:09 | |
It looks like that crash is caused by some bug in the implementation of PyUnicode_FromFormat(). I rewrote my patch to avoid it and added some additional unit tests. |
|||
| msg97070 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * ![]() |
Date: 2009-12-30 23:39 | |
The tests were missing in my last patch. So, here's a new one. |
|||
| msg97613 - (view) | Author: Alexandre Vassalotti (alexandre.vassalotti) * ![]() |
Date: 2010-01-11 23:17 | |
Committed in r77428. Thanks for your comments! |
|||
| msg349107 - (view) | Author: Thomas Grainger (graingert) * | Date: 2019-08-06 13:15 | |
It seems that 'viewkeys', 'viewvalues' and 'viewitems' methods were not added to types.DictProxyType, was that intentional? |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:30 | admin | set | github: 46259 |
| 2019-08-06 13:24:16 | python-dev | set | pull_requests: + pull_request14880 |
| 2019-08-06 13:15:47 | graingert | set | nosy:
+ graingert messages: + msg349107 |
| 2010-01-11 23:17:53 | alexandre.vassalotti | set | status: open -> closed resolution: accepted messages: + msg97613 stage: patch review -> resolved |
| 2009-12-30 23:39:07 | alexandre.vassalotti | set | files:
+ backport_dictviews-3.diff messages: + msg97070 |
| 2009-12-30 23:09:27 | alexandre.vassalotti | set | files:
+ backport_dictviews-2.diff messages: + msg97066 |
| 2009-12-11 22:59:29 | ezio.melotti | set | keywords:
+ needs review, - 26backport nosy: + ezio.melotti messages: + msg96276 |
| 2009-12-11 14:17:26 | alexandre.vassalotti | set | messages: + msg96258 |
| 2009-08-04 23:53:20 | alexandre.vassalotti | set | files:
+ 2to3_fixer_dictviews.diff messages: + msg91286 |
| 2009-08-04 23:51:25 | alexandre.vassalotti | set | files:
+ backport_dictviews.diff nosy:
+ alexandre.vassalotti stage: patch review |
| 2008-08-21 14:49:12 | benjamin.peterson | set | title: Backport dictviews to 2.6 -> Backport dictviews to 2.7 versions: + Python 2.7, - Python 2.6 |
| 2008-07-28 17:02:50 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg70359 |
| 2008-03-29 01:44:12 | georg.brandl | set | keywords: + 26backport |
| 2008-03-29 01:44:07 | georg.brandl | set | priority: normal -> critical |
| 2008-01-31 01:50:58 | twouters | set | files:
+ dictviews_backport.diff messages: + msg61881 |
| 2008-01-31 01:50:48 | twouters | set | files: - dictviews_backport.diff |
| 2008-01-30 09:54:11 | christian.heimes | set | priority: normal type: enhancement |
| 2008-01-29 22:39:04 | twouters | create | |
