Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102652

Set Operations on Dicts

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Marco Kaulea <marco.kaulea@gmail.com>
Newsgroups comp.lang.python
Subject Set Operations on Dicts
Date Mon, 8 Feb 2016 10:56:43 +0100
Lines 19
Message-ID <mailman.86.1454925476.2317.python-list@python.org> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 8Fg+Jxev6OL80oBFr4kMRAfF6Wo/lqO4yj/Ntnn6M3JQ==
Return-Path <marco.kaulea@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.132
X-Spam-Level *
X-Spam-Evidence '*H*': 0.74; '*S*': 0.00; 'implemented.': 0.09; 'example:': 0.10; 'received:io': 0.16; 'received:psf.io': 0.16; "{'a':": 0.16; 'basically': 0.18; 'received:209.85.214.174': 0.22; 'exists.': 0.22; 'sets': 0.23; 'feature': 0.24; 'message- id:@mail.gmail.com': 0.27; 'operations': 0.31; '[1]': 0.32; 'surprised': 0.33; 'values.': 0.33; 'received:google.com': 0.35; 'should': 0.36; 'needed': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'received:209': 0.38; 'hi,': 0.38; 'received:209.85.214': 0.39; 'to:addr:python.org': 0.40; 'easy': 0.60; '&amp;': 0.61; 'spend': 0.67; 'worth': 0.67; 'url:v': 0.72; 'url:youtube': 0.73; 'url:watch': 0.78; 'subject:Set': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=xgbJB1V/NLf08qUVVV/1L1XXSck9H1gXrjwSHnpaOto=; b=0rLOjgDoPKxUxi8lhuP+/A2YEtrLYEfRWfBOF2rVjby4DaGFseFQJj2KFfMg2zHA+D IjvqBfNzJTYSdVtKkO/LKsGJSbIGbyW4+qCgZylf33wmI0COEfbYtbggUkXIy4e+OCcd r32ToEC1ib7/zyh34BFxI8q7Pb3M6XbuL1QKpAJUPWk97s6ES7r9KuFaSEtMWhPci7g5 nIzBbGoOJ2ToRB+YxcEbqwa+s0/wY4GEFwiBg+jvkyBtKXYF/LutVqsw4+su566Fc83E ZEjCct0BZ0hHjNuwEVubk7LCUs+LjCAtcN8GLVRBf144K+lGWT4ReLcM/djWMJPccV1H pg2Q==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=xgbJB1V/NLf08qUVVV/1L1XXSck9H1gXrjwSHnpaOto=; b=HR8qd04lh/38TUswwuMKvC9JxFER4/w3LUgXmK6Ibb6PaCYaryhvSEy5THDvtezh3+ dcbayKIRdRrlYpn/are/eBJaqImAsP5JYimMZX47JUgWg4wFqhKEn3FUaQZqNbgH6OKM 00auDjTMsQd3d+DDFZVL82QfPY5LhOUYtUj67B0k+fXC8T7U+dKDjt7HJ52q5MbFvTiB T4QgrlmXFev7RWKYl+2FHlFSHTCgY6Ec6Yq1oP01Rd7owOcbsp0AyAogoi4tw65gzkVL eaX2bkvx3AB2a0++2ZPZS13bcULA2OYKm4hQNLNpJcfwuo75ed1fvI/gro0ajef0d3di NQbw==
X-Gm-Message-State AG10YOSQs3iHyHyVoVtM4LHHkXKWs4ueBM7JtJ7sDh81BA5knGanpoivHKo6T8YdVt4rsa3lusUJ/trq2QzzWw==
X-Received by 10.60.220.230 with SMTP id pz6mr24287646oec.49.1454925423115; Mon, 08 Feb 2016 01:57:03 -0800 (PST)
X-Mailman-Approved-At Mon, 08 Feb 2016 04:57:56 -0500
X-Content-Filtered-By Mailman/MimeDel 2.1.21rc2
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:102652

Show key headers only | View raw


Hi,

In one talk (I think it was [1]) it was described that sets are basically
dicts without the values.
Therefor it should be easy to apply set operations on dicts, for example:
{'a': 123, 'b': 456} & {'a'} => {'a': 123}
{'a': 123, 'b': 456} - {'a'} => {'b': 456}

This if currently not implemented. Is there a technical reason that this is
difficult or are
there a lot of corner cases that make it not worth the trouble?

I have not spend a lot of time on this, I just needed a feature like that
and was surprised that
it did not exists.

- Marco

[1] https://www.youtube.com/watch?v=C4Kc8xzcA68

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Set Operations on Dicts Marco Kaulea <marco.kaulea@gmail.com> - 2016-02-08 10:56 +0100
  Re: Set Operations on Dicts Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-02-08 14:17 +0200
    Re: Set Operations on Dicts Marco Kaulea <marco.kaulea@gmail.com> - 2016-02-08 13:33 +0100
    Re: Set Operations on Dicts Matt Wheeler <m@funkyhat.org> - 2016-02-08 13:32 +0000
      Re: Set Operations on Dicts Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-02-08 16:02 +0200
    Re: Set Operations on Dicts Random832 <random832@fastmail.com> - 2016-02-08 09:52 -0500
      Re: Set Operations on Dicts Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-02-08 17:05 +0200
  Re: Set Operations on Dicts Grobu <snailcoder@retrosite.invalid> - 2016-02-08 13:47 +0100
    Re: Set Operations on Dicts Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-08 09:12 -0700
      Re: Set Operations on Dicts Grobu <snailcoder@retrosite.invalid> - 2016-02-09 08:21 +0100
        Re: Set Operations on Dicts Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-09 08:14 -0700

csiph-web