Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76935
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <joshua.landau.ws@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'formatting': 0.09; 'imported': 0.09; 'spec': 0.09; 'sure,': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; '(there': 0.16; '24,': 0.16; 'called,': 0.16; 'dig': 0.16; 'function),': 0.16; 'rounding': 0.16; 'so.': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; '>>>': 0.22; 'import': 0.22; 'aug': 0.22; 'putting': 0.22; 'cc:addr:python.org': 0.22; 'math': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'dramatic': 0.31; 'time;': 0.31; "i'd": 0.34; 'subject:with': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'should': 0.36; 'too': 0.37; 'performance': 0.37; 'anything': 0.39; 'does': 0.39; 'august': 0.61; 'you.': 0.62; 'times': 0.62; 'to:addr:gmail.com': 0.65; 'improvement.': 0.68; 'cuts': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=f37UYNJmTTdwYy87kdZwUW6V/WEvK02UHTC7YEWR2Ko=; b=N6ASMQub6IblDE9j5OY3QIyp3zj6ZtEQ1CZWpTOelpylGaVeARLdLoFCozwS+2Tr9F JVrlitl8Y5wt4T5uTxJV+krIVDIAuDYnfbjzBe1ZgbfCbHwqRRjilWpPAuSvCXlzufat A0mN2Kidls78kI3DvOtThVpuVza3qi6lNUNaJytGB9sC25i3hRjAwd/6nE1EvFH/DYYH dr9Bg857sB5Lj7/YqzJxBg6QrB1PA8p6qbV4XQ2l2BYoFYKo+ev/HL2RInsTeo4f4GUS PjbeAtZQy5KNxgI5hqGKBrtVSFGf641yFz0G9E1pSs96JTkZmi3IBfQ58RU/piD5RpoH qS6g== |
| X-Received | by 10.112.198.34 with SMTP id iz2mr3065571lbc.96.1408907577433; Sun, 24 Aug 2014 12:12:57 -0700 (PDT) |
| MIME-Version | 1.0 |
| Sender | joshua.landau.ws@gmail.com |
| In-Reply-To | <CAPTjJmpRwPj2huRNAFWzbCPT5PAJga6ORC96PKo2EQ7hedozOg@mail.gmail.com> |
| References | <vrihv9l5sce3bkreceav5uhkaqdo9dqnri@4ax.com> <ek0iv9diq2io1126te9j5pppoilstfuvdo@4ax.com> <CAN1F8qXtRbPiQ_W93iFLcaxT40B2uoeg_aZ8aYYhQvP7FCShqQ@mail.gmail.com> <CAPTjJmq26CwkwWE_32_C9CKXFsfnE1bb-jwW7dE2HkZ6EyW40Q@mail.gmail.com> <CAN1F8qUnUWk06uBXe0D-0V1HBuhM7j_Pxcqgb4y61kvh7ioygA@mail.gmail.com> <CAPTjJmpRwPj2huRNAFWzbCPT5PAJga6ORC96PKo2EQ7hedozOg@mail.gmail.com> |
| From | Joshua Landau <joshua@landau.ws> |
| Date | Sun, 24 Aug 2014 20:12:17 +0100 |
| X-Google-Sender-Auth | HQ7nAYB82ueduIxzZ8wqPvQb8JE |
| Subject | Re: Working with decimals |
| To | Chris Angelico <rosuav@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list <python-list@python.org> |
| 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 | <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.13379.1408907584.18130.python-list@python.org> (permalink) |
| Lines | 29 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1408907585 news.xs4all.nl 2934 [2001:888:2000:d::a6]:45254 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:76935 |
Show key headers only | View raw
On 23 August 2014 23:53, Chris Angelico <rosuav@gmail.com> wrote: > On Sun, Aug 24, 2014 at 8:47 AM, Joshua Landau <joshua@landau.ws> wrote: >> On 23 August 2014 23:31, Chris Angelico <rosuav@gmail.com> wrote: >>> I'd say "never" is too strong (there are times when it's right to put >>> an import inside a function), but yes, in this case it should really >>> be at the top of the function. >> >> But do any of them apply to "import math"? > > Yep. If you have only one function that will ever use it, and that > function often won't ever be called, then putting the import inside > the function speeds up startup. Anything that cuts down on I/O can > give a dramatic performance improvement. >>> python -c "import time; a = time.time(); import math; b = time.time(); print(b-a)" 0.0005981922149658203 *squints eyes* Is math not already imported by start-up? >>> However, you won't need the import at all if you let the formatting >>> function do the rounding for you. >> >> Can that floor? > > I'm not sure, dig into the format spec and see! FWIW, I haven't seen something that does so.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Working with decimals Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-23 13:47 -0400
Re: Working with decimals Joel Goldstick <joel.goldstick@gmail.com> - 2014-08-23 14:21 -0400
Re: Working with decimals Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-23 15:07 -0400
Re: Working with decimals Joel Goldstick <joel.goldstick@gmail.com> - 2014-08-23 15:22 -0400
Re: Working with decimals Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-23 20:24 +0100
Re: Working with decimals Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-23 15:48 -0400
Re: Working with decimals Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-23 21:31 +0100
Re: Working with decimals Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-23 17:13 -0400
Re: Working with decimals Joshua Landau <joshua@landau.ws> - 2014-08-23 22:47 +0100
Re: Working with decimals Chris Angelico <rosuav@gmail.com> - 2014-08-24 08:31 +1000
Re: Working with decimals Joshua Landau <joshua@landau.ws> - 2014-08-23 23:47 +0100
Re: Working with decimals Chris Angelico <rosuav@gmail.com> - 2014-08-24 08:53 +1000
Re: Working with decimals Larry Hudson <orgnut@yahoo.com> - 2014-08-24 00:04 -0700
Re: Working with decimals Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-24 10:58 -0400
Re: Working with decimals Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-24 11:12 -0400
Re: Working with decimals Larry Hudson <orgnut@yahoo.com> - 2014-08-24 14:24 -0700
Re: Working with decimals Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-24 19:07 -0400
Re: Working with decimals Joshua Landau <joshua@landau.ws> - 2014-08-24 20:12 +0100
Re: Working with decimals Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-24 13:17 -0600
Re: Working with decimals Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-24 13:19 -0600
Re: Working with decimals Joshua Landau <joshua@landau.ws> - 2014-08-24 20:25 +0100
Re: Working with decimals Joshua Landau <joshua@landau.ws> - 2014-08-24 20:29 +0100
Re: Working with decimals Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-25 12:16 +1000
Re: Working with decimals Chris Angelico <rosuav@gmail.com> - 2014-08-25 12:27 +1000
Re: Working with decimals Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-08-25 12:51 +1000
Re: Working with decimals Chris Angelico <rosuav@gmail.com> - 2014-08-25 13:01 +1000
Re: Working with decimals Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-24 13:37 -0600
Re: Working with decimals Ian Kelly <ian.g.kelly@gmail.com> - 2014-08-24 13:40 -0600
Re: Working with decimals Joshua Landau <joshua@landau.ws> - 2014-08-24 20:49 +0100
Re: Working with decimals Joshua Landau <joshua@landau.ws> - 2014-08-23 22:52 +0100
Re: Working with decimals Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-23 18:03 -0400
csiph-web