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


Groups > comp.lang.python > #79417

Re: (-1)**1000

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=3657501fa=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.070
X-Spam-Evidence '*H*': 0.86; '*S*': 0.00; 'interpreter': 0.05; 'wednesday,': 0.07; 'module)': 0.09; 'thx': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; 'assume': 0.14; 'suggest': 0.14; "(it's": 0.16; '(you': 0.16; 'language': 0.16; 'do.': 0.18; 'module': 0.19; 'tests': 0.22; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'program,': 0.31; 'clever': 0.31; 'embed': 0.31; 'interface': 0.32; 'community': 0.33; '-----': 0.33; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'yield': 0.36; 'done': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.37; 'thank': 0.38; 'fact': 0.38; 'subject:': 0.39; 'results.': 0.60; 'most': 0.60; "you're": 0.61; 'you.': 0.62; 'information': 0.63; 'received:194': 0.64; 'provide': 0.64; 'email name:python-list': 0.65; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'heavy': 0.81; 'potentially': 0.81; 'lifting': 0.84; 'url:reference': 0.84; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="5.04,767,1406584800"; d="scan'208";a="3485858"
Date Wed, 22 Oct 2014 10:39:04 +0200 (CEST)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To ast <nomail@invalid.com>
In-Reply-To <54476a77$0$21664$426a74cc@news.free.fr>
Subject Re: (-1)**1000
MIME-Version 1.0
X-Mailer Zimbra 7.2.7_GA_2942 (ZimbraWebClient - GC37 (Linux)/7.2.7_GA_2942)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc 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.15057.1413967158.18130.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1413967158 news.xs4all.nl 2957 [2001:888:2000:d::a6]:41854
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:79417

Show key headers only | View raw


----- Original Message -----
> From: "ast" <nomail@invalid.com>
> To: python-list@python.org
> Sent: Wednesday, 22 October, 2014 10:27:34 AM
> Subject: (-1)**1000
> 
> Hello
> 
> If i am writing (-1)**1000 on a python program, will the
> interpreter do (-1)*(-1)*...*(-1) or something clever ?
> 
> In fact i have (-1)**N with N an integer potentially big.
> 
> I do some tests that suggest that Python is clever
> 
> thx

Python will yield the correct results. That is the most clever thing to do.
If you really worried about execution speed (I assume that what your question implies), Python may not be the language you need.

However, know that there are these modules "numpy" and "scipy" which are used by the scientific community which provide a python interface (it's a python module) but most of the heavy lifting is done in C (you can embed C in python code). 

For instance
http://docs.scipy.org/doc/numpy/reference/generated/numpy.power.html

Use this module if speed is what you're looking for.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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


Thread

Re: (-1)**1000 Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-10-22 10:39 +0200

csiph-web