Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87637
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.014 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'python3': 0.07; 'received:151': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:skip:c 10': 0.09; '10000000': 0.16; 'comp': 0.16; 'dict': 0.16; 'emanuele': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'seems': 0.21; 'header:User-Agent:1': 0.23; 'header:X-Complaints- To:1': 0.27; 'function': 0.29; 'writes:': 0.31; 'call.': 0.33; 'there': 0.35; 'subject:?': 0.36; 'should': 0.36; 'to:addr:python- list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'che': 0.60; 'taking': 0.65; 'account?': 0.68; 'sound': 0.68; 'faster.': 0.84; 'quando': 0.84; 'factors': 0.97 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Lele Gaifax <lele@metapensiero.it> |
| Subject | Re: Dict comprehensions - improvement to docs? |
| Date | Tue, 17 Mar 2015 15:06:08 +0100 |
| Organization | Nautilus Entertainments |
| References | <mailman.410.1426483550.21433.python-list@python.org> <87fv95fom0.fsf@jester.gateway.sonic.net> <mailman.427.1426494675.21433.python-list@python.org> <87wq2hfibu.fsf@jester.gateway.sonic.net> <me664q$hon$1@ger.gmane.org> <CALwzid=u19YMkfJBhbLZi1qh2U9UK4ohY5wco1zO-i3T5AtyOA@mail.gmail.com> <me8ige$kjp$1@ger.gmane.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Gmane-NNTP-Posting-Host | 151.62.17.65 |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4.91 (gnu/linux) |
| Cancel-Lock | sha1:xvr3OZqcSnDEjqZNN46BW6F8fvs= |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.495.1426601188.21433.python-list@python.org> (permalink) |
| Lines | 20 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1426601188 news.xs4all.nl 2934 [2001:888:2000:d::a6]:60826 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Bytes | 3472 |
| X-Received-Body-CRC | 3154978226 |
| Xref | csiph.com comp.lang.python:87637 |
Show key headers only | View raw
"Frank Millman" <frank@chagford.com> writes:
> It seems that a dict comp is noticeably faster.
>
> Does this sound right, or are there other factors I should be taking into
> account?
The dict comp does not execute any function call. Consider the following:
$ python3 -m timeit "d=dict()"
10000000 loops, best of 3: 0.113 usec per loop
$ python3 -m timeit "d={}"
10000000 loops, best of 3: 0.0601 usec per loop
ciao, lele.
--
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it | -- Fortunato Depero, 1929.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Dict comprehensions - improvement to docs? "Frank Millman" <frank@chagford.com> - 2015-03-16 07:25 +0200
Re: Dict comprehensions - improvement to docs? Paul Rubin <no.email@nospam.invalid> - 2015-03-15 23:22 -0700
Re: Dict comprehensions - improvement to docs? "Frank Millman" <frank@chagford.com> - 2015-03-16 10:30 +0200
Re: Dict comprehensions - improvement to docs? Paul Rubin <no.email@nospam.invalid> - 2015-03-16 01:38 -0700
Re: Dict comprehensions - improvement to docs? "Frank Millman" <frank@chagford.com> - 2015-03-16 11:01 +0200
Re: Dict comprehensions - improvement to docs? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-16 09:57 -0600
Re: Dict comprehensions - improvement to docs? Paul Rubin <no.email@nospam.invalid> - 2015-03-16 15:41 -0700
Re: Dict comprehensions - improvement to docs? "Frank Millman" <frank@chagford.com> - 2015-03-17 08:44 +0200
Re: Dict comprehensions - improvement to docs? Lele Gaifax <lele@metapensiero.it> - 2015-03-17 15:06 +0100
Re: Dict comprehensions - improvement to docs? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-17 09:48 -0600
Re: Dict comprehensions - improvement to docs? "Frank Millman" <frank@chagford.com> - 2015-03-18 10:01 +0200
Re: Dict comprehensions - improvement to docs? Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-18 02:39 -0600
csiph-web