On Wed, Jul 01, 2020 at 12:10:12PM +0100, Rhodri James wrote:
On 01/07/2020 11:24, Steven D'Aprano wrote:
On Tue, Jun 30, 2020 at 07:40:23PM +0100, Rhodri James wrote:
Don't get me wrong, if it's not going to cause performance issues I think being able to index views would be great
What are your use-cases for indexing set-like views of a dict?
Personally none, but that's because I still don't treat dicts as being ordered and arrange my data structures accordingly. I seem to remember the OP having a use case, and I can imagine people who have ordering ingrained in their style rather harder than me could find uses.
The OP's use-case, as far as I can tell, would not actually be helped by adding indexing to dicts. He has a table of columns, and needs to insert and delete columns into any position, including slices of multiple columns. As far as I can see, the OP should be using a list of columns, not a dict, perhaps augmented by a mapping of column-names to column position (assuming the names are unique). Or maybe some fancier data structure designed for this purpose. -- Steven