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


Groups > comp.lang.python > #79417 > unrolled thread

Re: (-1)**1000

Started byJean-Michel Pichavant <jeanmichel@sequans.com>
First post2014-10-22 10:39 +0200
Last post2014-10-22 10:39 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

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

#79417 — Re: (-1)**1000

FromJean-Michel Pichavant <jeanmichel@sequans.com>
Date2014-10-22 10:39 +0200
SubjectRe: (-1)**1000
Message-ID<mailman.15057.1413967158.18130.python-list@python.org>
----- 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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web