Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45725
| Path | csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <carlosnepomuceno@outlook.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.024 |
| X-Spam-Evidence | '*H*': 0.95; '*S*': 0.00; 'cpython': 0.05; 'great.': 0.07; 'subject:PEP': 0.07; 'variables': 0.07; 'implements': 0.09; '2.7': 0.14; '1.05': 0.16; '10000000': 0.16; 'cases)': 0.16; 'comma': 0.16; 'literals': 0.16; 'operator.': 0.16; 'received:65.55.116.7': 0.16; 'str.format()': 0.16; 'wed,': 0.18; 'to:name:python-list@python.org': 0.22; 'features,': 0.24; 'received:65.55.116': 0.24; 'skip:% 10': 0.24; 'header:In-Reply- To:1': 0.27; 'skip:- 40': 0.29; 'patch': 0.29; 'getting': 0.31; 'skip:c 30': 0.32; 'raw': 0.33; 'date:': 0.34; 'problem.': 0.35; 'test': 0.35; 'but': 0.35; 'wrong': 0.37; 'to:addr:python-list': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'new': 0.61; 'matter': 0.61; 'different': 0.65; 'optimized': 0.68; 'default': 0.69; '50%': 0.78; 'gain': 0.79; 'discovered': 0.83; '2.7.': 0.84; 'treats': 0.84; '2013': 0.98 |
| X-TMN | [nWtJfd/+nBQEy3KQsQytpd7A4Qm7ZdI/] |
| X-Originating-Email | [carlosnepomuceno@outlook.com] |
| From | Carlos Nepomuceno <carlosnepomuceno@outlook.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Subject | RE: PEP 378: Format Specifier for Thousands Separator |
| Date | Wed, 22 May 2013 14:52:15 +0300 |
| Importance | Normal |
| In-Reply-To | <519CAB19.7080203@nedbatchelder.com> |
| References | <knghok$3bd$1@ger.gmane.org> <519c36c6$0$6599$c3e8da3$5496439d@news.astraweb.com> <519CAB19.7080203@nedbatchelder.com> |
| Content-Type | text/plain; charset="iso-8859-1" |
| Content-Transfer-Encoding | quoted-printable |
| MIME-Version | 1.0 |
| X-OriginalArrivalTime | 22 May 2013 11:52:15.0380 (UTC) FILETIME=[CDB03D40:01CE56E2] |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| 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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1961.1369223544.3114.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1369223544 news.xs4all.nl 15905 [2001:888:2000:d::a6]:51929 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:45725 |
Show key headers only | View raw
----------------------------------------
> Date: Wed, 22 May 2013 07:25:13 -0400
> From: ned@nedbatchelder.com
[...]
> You have to keep in mind that 2.7 is not getting any new features, no
> matter how small they seem. If you create a patch that implements the
> comma flag in %-formatting, it *might* go into 3.x, but it will not go
> into 2.7.
>
> --Ned.
No problem. I have just discovered i was measuring the wrong thing.
My test case is been optimized at compile time by CPython that treats "'%d' % 12345" as a constant.
My use case is different because I almost have no literals been used with % operator.
So my gain isn't that great. In fact it's faster with str.format() than %, and it's even faster if I use the default format specifier.
C:\Python27>python -m timeit -cv -n10000000 -s"v=12345" "'%d'%v"
raw times: 10.5 10.7 10.7
10000000 loops, best of 3: 1.05 usec per loop
C:\Python27>python -m timeit -cv -n10000000 -s"v=12345" "'{:d}'.format(v)"
raw times: 8.11 8.09 8.02
10000000 loops, best of 3: 0.802 usec per loop
C:\Users\Josue\Documents\Python>python -m timeit -cv -n10000000 -s"v=12345" "'{}'.format(v)"
raw times: 5.3 5.5 5.62
10000000 loops, best of 3: 0.53 usec per loop
Using variables (100% of cases) makes str.format() 50% faster than %.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-21 23:22 +0300
Re: PEP 378: Format Specifier for Thousands Separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-22 02:42 +0000
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-22 05:56 +0300
Re: PEP 378: Format Specifier for Thousands Separator Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-22 03:08 +0000
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-22 06:38 +0300
Re: PEP 378: Format Specifier for Thousands Separator 88888 Dihedral <dihedral88888@gmail.com> - 2013-05-22 00:14 -0700
Re: PEP 378: Format Specifier for Thousands Separator Ned Batchelder <ned@nedbatchelder.com> - 2013-05-22 07:25 -0400
RE: PEP 378: Format Specifier for Thousands Separator Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-05-22 14:52 +0300
csiph-web