[issue6326] Add a "swap" method to list

2009-07-01 Thread Antoine Pitrou
Antoine Pitrou added the comment: Even if C++ decides it's an useful feature, it's not a sufficient reason to add it to Python! Based on previous discussion and the converging advice of others, this bug can IMO be closed. -- resolution: -> rejected status: open -> closed _

[issue6326] Add a "swap" method to list

2009-06-30 Thread Kristján Valur Jónsson
Kristján Valur Jónsson added the comment: fyi, here is the thread from python-ideas: http://mail.python.org/pipermail/python-ideas/2009-June/005042.html The parallel to C++´s future "rvalue reference" is interesting (http://www.artima.com/cppsource/rvalue.html, see the "move" application)

[issue6326] Add a "swap" method to list

2009-06-30 Thread Adam Olsen
Adam Olsen added the comment: Fix it at its source: patch your database engine to use the type you want. Or wrap the list without subclassing (__iter__ may be the only method you need to wrap). Obscure performance hacks don't warrant language extensions. -- nosy: +Rhamphoryncus _

[issue6326] Add a "swap" method to list

2009-06-24 Thread Antoine Pitrou
Antoine Pitrou added the comment: -1 from me. It is too marginal and obscure an use case to warrant a dedicated method on a builtin type. -- nosy: +pitrou ___ Python tracker ___

[issue6326] Add a "swap" method to list

2009-06-23 Thread Raymond Hettinger
Changes by Raymond Hettinger : Removed file: http://bugs.python.org/file14345/mview2.diff ___ Python tracker ___ ___ Python-bugs-list mailing l

[issue6326] Add a "swap" method to list

2009-06-23 Thread Raymond Hettinger
Changes by Raymond Hettinger : Added file: http://bugs.python.org/file14345/mview2.diff ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue6326] Add a "swap" method to list

2009-06-23 Thread Kristján Valur Jónsson
Kristján Valur Jónsson added the comment: Indeed, I realized that it does allow overriding all kinds of behaviour and as such may be dangerous for the unwary. But isn't it possible to do so anyway? One way to increase safety would be to require that the "other" list is not a subclass (PyLis

[issue6326] Add a "swap" method to list

2009-06-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, the technique is useful and fast, but it is complicated in its effects. I used something similar in the set_swap_bodies() internal code for set and frozenset objects but avoided exposing the behavior externally. -- status: pending -> open ___

[issue6326] Add a "swap" method to list

2009-06-23 Thread R. David Murray
R. David Murray added the comment: There are clearly enough subtleties to this proposal that it should be discussed on python-ideas first. If a consensus is reached you can reopen this ticket, referencing the discussion thread. -- nosy: +r.david.murray priority: -> low status: open ->

[issue6326] Add a "swap" method to list

2009-06-23 Thread Raymond Hettinger
Raymond Hettinger added the comment: > One application of this is to make help a performance problem when one > wants to upgrade a list instance into a subclass instance. Since this bypasses the subclass's __init__ and other methods, doesn't it risk violating subclass invariants? class CapLis

[issue6326] Add a "swap" method to list

2009-06-23 Thread Kristján Valur Jónsson
New submission from Kristján Valur Jónsson : It is sometimes useful to be able to swap the contents of two lists and this patch provides a way to do so using the fastest way possible. > a = [1, 2] > b = [3] > id(a), id(b) (100, 101) > a.swap(b) > a [3] > b [1, 2] > id(a), id(b) (100, 101) One