[issue14386] Expose dictproxy as a public type

2012-03-30 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- type: - enhancement ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386 ___ ___

[issue14386] Expose dictproxy as a public type

2012-03-29 Thread poq
poq p...@gmx.com added the comment: It is exposed as types.DictProxyType in Python 2... -- nosy: +poq ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386 ___

[issue14386] Expose dictproxy as a public type

2012-03-29 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: It is exposed as types.DictProxyType in Python 2... Yes, but the purpose of the issue is to enable its constructor. You cannot instanciate a DictProxy in Python 2: import types types.DictProxyType type 'dictproxy'

[issue14386] Expose dictproxy as a public type

2012-03-29 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386 ___

[issue14386] Expose dictproxy as a public type

2012-03-29 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: Patch version 4, it is ready for a review. Summary of the patch: - expose the internal dict_proxy() type (used for __dict__ of user classes) as types.MappingViewType (it was exposed a types.DictProxyType in Python 2) -

[issue14386] Expose dictproxy as a public type

2012-03-29 Thread Guido van Rossum
Guido van Rossum gu...@python.org added the comment: I'd like to bikeshed a little on the name. I think it should be MappingProxy. (We don't use view much but the place where we do use it, for keys/values/items views, is very different I think. Also collections.abc already defines MappingView as

[issue14386] Expose dictproxy as a public type

2012-03-29 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: (We don't use view much but the place where we do use it, for keys/values/items views, is very different I think.) You are right, it's closer to a proxy because it has the same methods than a mapping (except of some methods used to

[issue14386] Expose dictproxy as a public type

2012-03-29 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: Oh, collections.abc contains also the mappingview type exposed with the name dict_proxy: dict_proxy = type(type.__dict__) It was exposed as _abcoll.dict_proxy in Python 3.2. It is not documented. Should we keep it for backward

[issue14386] Expose dictproxy as a public type

2012-03-29 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: MappingView is a strange ABC: it should probably declare __contains__ as an abstract method. I think that was not done because it would not be very useful: MappingView seems to exist only as a base class for the other *View, which define

[issue14386] Expose dictproxy as a public type

2012-03-28 Thread Georg Brandl
Georg Brandl ge...@python.org added the comment: But it has nothing to do with weakrefs, so... -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386 ___

[issue14386] Expose dictproxy as a public type

2012-03-28 Thread Guido van Rossum
Guido van Rossum gu...@python.org added the comment: Since it has to go *somewhere*, let's put it in the types module. It has a variety of other types that are used in the implementation of classes and functions and related things. -- ___ Python

[issue14386] Expose dictproxy as a public type

2012-03-28 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: [GvR] Since it has to go *somewhere*, let's put it in the types module. It has a variety of other types that are used in the implementation of classes and functions and related things. +1 --

[issue14386] Expose dictproxy as a public type

2012-03-27 Thread Giampaolo Rodola'
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386 ___ ___

[issue14386] Expose dictproxy as a public type

2012-03-27 Thread Antoine Pitrou
Antoine Pitrou pit...@free.fr added the comment: There's already a weak proxy class in the weakref module. Not sure a separate module for the other proxies is a good idea. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org

[issue14386] Expose dictproxy as a public type

2012-03-27 Thread Michael Foord
Michael Foord mich...@voidspace.org.uk added the comment: If we do create a proxy module I'd like to suggest adding all or part of Phillip Eby's ProxyTypes: http://pypi.python.org/pypi/ProxyTypes I haven't used it directly, but did read through it a while ago and have ended up

[issue14386] Expose dictproxy as a public type

2012-03-27 Thread Éric Araujo
Éric Araujo mer...@netwok.org added the comment: weakref.mappingview sounds nice to me. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386 ___

[issue14386] Expose dictproxy as a public type

2012-03-26 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: New patch replacing dictproxy() builtin type with collections.mappingview() type: - dictproxy() type doesn't need to be a builtin type - it is not specific to dict so replace dict prefix with mapping - view is a better suffix than

[issue14386] Expose dictproxy as a public type

2012-03-26 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: I would very much like this to go somewhere other than the collections module. As the maintainer of that module, I've worked hard to keep it clutter free (people frequently want to stick things in that module when they can't

[issue14386] Expose dictproxy as a public type

2012-03-26 Thread Guido van Rossum
Guido van Rossum gu...@python.org added the comment: Raymond, that sounds like a very irrational way of deciding where it should go. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386

[issue14386] Expose dictproxy as a public type

2012-03-26 Thread Stefan Krah
Stefan Krah stefan-use...@bytereef.org added the comment: I wonder about the name: There is already a collections.abc.MappingView. -- nosy: +skrah ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386

[issue14386] Expose dictproxy as a public type

2012-03-26 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: The weakref collections objects (sets, dicts, etc) were all put in a separate module and that has worked out well. I suggest doing the same for proxy objects. In maintaining the itertools module, I learned long ago that adding

[issue14386] Expose dictproxy as a public type

2012-03-26 Thread Guido van Rossum
Guido van Rossum gu...@python.org added the comment: I like the suggestion of a library module containing proxy classes. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386 ___

[issue14386] Expose dictproxy as a public type

2012-03-25 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: A sequence *does* meet the (immutable) Mapping interface Ah? Let's try: x=[1, 2, 3] x.get(2) AttributeError: 'list' object has no attribute 'get' x.keys() AttributeError: 'list' object has no attribute 'keys' list doesn't

[issue14386] Expose dictproxy as a public type

2012-03-25 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: The PyMapping_Check(dict) !PyMapping_Check(dict) Oh, I mean PyMapping_Check(dict) !PySequence_Check(dict) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386

[issue14386] Expose dictproxy as a public type

2012-03-25 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: I'm -1 on exposing this API. Victor's sandboxing project doesn't warrant cluttering the public toolset. As a consultant who gets to see many large codebases in different companies and I see zero need for this type to be exposed.

[issue14386] Expose dictproxy as a public type

2012-03-25 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: I believe it was actually Guido who suggested exposing dict_proxy, in response to Victor (but independent of Victor's needs, if I understood the message correctly). It has always seemed odd to me (always referring my time working with

[issue14386] Expose dictproxy as a public type

2012-03-25 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: Victor's use case is unique in that he needs the type to be implemented in C. mxProxy, zope.proxy and zope.security implement object proxies in C (for security purpose). These proxies are not specific to dict, but are generic.

[issue14386] Expose dictproxy as a public type

2012-03-25 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: It's clutter and we should show some restraint before adding new types. Enthought's Python Distribution isn't shy about adding tools when they have a demonstrated need. Likewise, Django adds any reusable tools they need.

[issue14386] Expose dictproxy as a public type

2012-03-25 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: It's clutter and we should show some restraint before adding new types. dictproxy() doesn't need to be a public builtin type. We can just implement its constructor without documenting the type. Or it may be exposed in a module like

[issue14386] Expose dictproxy as a public type

2012-03-25 Thread Guido van Rossum
Guido van Rossum gu...@python.org added the comment: Given that dictproxy is needed to implement the proper interface for classes I don't think it is an implementation detail, and so I think it ought to be constructable. We have more esoteric types constructable (e.g. function). I also happen

[issue14386] Expose dictproxy as a public type

2012-03-25 Thread Raymond Hettinger
Raymond Hettinger raymond.hettin...@gmail.com added the comment: [haypo] dictproxy() doesn't need to be a public builtin type. +1 We can just implement its constructor without documenting the type. +1 Or it may be exposed in a module like collections. Please don't use collections as a

[issue14386] Expose dictproxy as a public type

2012-03-22 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: Patch version 2: - add tests and documentation - dictproxy code moved to dictproxyobject.c - dict_proxy replaced with dictproxy in repr(dictproxy) - key in dictproxy now handles correctly dict subclasses - dictproxy constructor

[issue14386] Expose dictproxy as a public type

2012-03-22 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: The dictproxy is useful to implement a Python sandbox: see the related issue #14385. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386

[issue14386] Expose dictproxy as a public type

2012-03-22 Thread Jim Jewett
Jim Jewett jimjjew...@gmail.com added the comment: The problem is to reject sequence in dictproxy constructor. Why? Just because you can't delegate in quite the same way? A sequence *does* meet the (immutable) Mapping interface; it just won't happen to have any non-integer keys. Or are

[issue14386] Expose dictproxy as a public type

2012-03-21 Thread STINNER Victor
New submission from STINNER Victor victor.stin...@gmail.com: Attached patch makes the dictproxy type public. Example: $ ./python Python 3.3.0a1+ (default:059489cec7b9+, Mar 22 2012, 02:45:36) d=dictproxy({1:2}) d dict_proxy({1: 2}) d[1] 2 d[1]=3 TypeError: 'dictproxy' object does not

[issue14386] Expose dictproxy as a public type

2012-03-21 Thread STINNER Victor
STINNER Victor victor.stin...@gmail.com added the comment: dictproxy.patch: proxy_new() should check that dict is a dict (PyDict_Check). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386

[issue14386] Expose dictproxy as a public type

2012-03-21 Thread Eric Snow
Changes by Eric Snow ericsnowcurren...@gmail.com: -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14386 ___ ___ Python-bugs-list