Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25371
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <leif.poorman@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; 'suggestions,': 0.07; 'python': 0.09; 'none.': 0.09; 'subset': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'pushed': 0.13; 'intersection': 0.16; 'operation.': 0.16; 'pythonic': 0.16; 'timed': 0.16; 'saying': 0.18; 'code.': 0.20; 'written': 0.20; 'bit': 0.21; 'thanks.': 0.21; "haven't": 0.23; 'cc:no real name:2**0': 0.24; 'cc:2**1': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'wrote': 0.26; 'common': 0.26; 'cc:addr:gmail.com': 0.27; 'implemented': 0.27; 'faster,': 0.29; 'idea,': 0.29; 'sets.': 0.29; 'case,': 0.29; "i'm": 0.29; 'e.g.': 0.30; 'could': 0.32; 'received:google.com': 0.34; 'thanks': 0.34; 'faster': 0.35; 'received:209.85': 0.35; 'really': 0.36; 'smaller': 0.36; '(for': 0.37; 'quite': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'where': 0.40; 'your': 0.60; 'most': 0.61; 'skip:n 10': 0.63; 'received:209.85.216.184': 0.84; 'deal,': 0.93 |
| Newsgroups | comp.lang.python |
| Date | Sun, 15 Jul 2012 12:47:26 -0700 (PDT) |
| In-Reply-To | <mailman.2146.1342373918.4697.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=76.97.43.12; posting-account=-rDhLQoAAABniRdj0n3RqIriCs8wG4fD |
| References | <38c6d4cb-89b3-4f78-a966-be5ddccec845@googlegroups.com> <mailman.2146.1342373918.4697.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 76.97.43.12 |
| MIME-Version | 1.0 |
| Subject | Re: Request for useful functions on dicts |
| From | Leif <leif.poorman@gmail.com> |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org, Leif <leif.poorman@gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.2151.1342381649.4697.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1342381649 news.xs4all.nl 6928 [2001:888:2000:d::a6]:38165 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:25371 |
Show key headers only | View raw
Thanks for the suggestions, Ian! I implemented most of them and pushed the code. > That's because the Pythonic way is to either create a new object and > return it, or mutate the existing object and return None. You're saying what I was already thinking. > In Python 2.7+, intersection and difference could be written using > dictviews, which act like sets. I'm debating with myself right now whether to support 2.5 and 2.6. > def partition(f, d): Good idea, thanks. > issubdict could be implemented as a subset operation. I haven't timed The current implementation is a bit faster, and it's quite a bit faster on the common (for me) case, where one argument is much smaller than the other. I wrote it that way because if m=len(first), n=len(second), the amount of work is O(min(m,n)). Your implementation is O(m + n). Not really a big deal, unless e.g. m << n. --Leif
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Request for useful functions on dicts Leif <leif.poorman@gmail.com> - 2012-07-14 16:56 -0700
Re: Request for useful functions on dicts Ian Kelly <ian.g.kelly@gmail.com> - 2012-07-15 11:38 -0600
Re: Request for useful functions on dicts Leif <leif.poorman@gmail.com> - 2012-07-15 12:47 -0700
Re: Request for useful functions on dicts Leif <leif.poorman@gmail.com> - 2012-07-15 12:47 -0700
csiph-web