Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41842
| References | <CAPTjJmouUzXNr4Oq==LYB1UZ2UQb13Y6vTHGGzuzNXorNthjYg@mail.gmail.com> <mailman.3705.1364253727.2939.python-list@python.org> <5150e900$0$29998$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| From | Oscar Benjamin <oscar.j.benjamin@gmail.com> |
| Date | 2013-03-26 00:49 +0000 |
| Subject | Re: Performance of int/long in Python 3 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3709.1364259012.2939.python-list@python.org> (permalink) |
On 26 March 2013 00:17, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > On Mon, 25 Mar 2013 16:16:05 -0700, Ethan Furman wrote: > [snip] >> If you're working with >> numbers, and speed is an issue, you really should be using one of the >> numeric or scientific packages out there. > [snip] > What I would like to see though is a module where I can import fixed- > width signed and unsigned integers that behave like in C, complete with > overflow, for writing code that matches the same behaviour as other > languages. Numpy can do this: >>> import numpy >>> a = numpy.array([0], numpy.uint32) >>> a array([0], dtype=uint32) >>> a[0] = -1 >>> a array([4294967295], dtype=uint32) Unfortunately it doesn't work with numpy "scalars", so to use this without the index syntax you'd need a wrapper class. Also it uses Python style floor rounding rather than truncation as in C (actually I seem to remember discovering that in C this is implementation defined). Presumably ctypes has something like this as well. Oscar
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Performance of int/long in Python 3 Ethan Furman <ethan@stoneleaf.us> - 2013-03-25 16:16 -0700
Re: Performance of int/long in Python 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-26 00:17 +0000
Re: Performance of int/long in Python 3 Chris Angelico <rosuav@gmail.com> - 2013-03-26 11:28 +1100
Re: Performance of int/long in Python 3 Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-03-26 00:49 +0000
Re: Performance of int/long in Python 3 Roy Smith <roy@panix.com> - 2013-03-25 20:55 -0400
Re: Performance of int/long in Python 3 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-26 05:01 +0000
Re: Performance of int/long in Python 3 Chris Angelico <rosuav@gmail.com> - 2013-03-26 17:12 +1100
Re: Performance of int/long in Python 3 Roy Smith <roy@panix.com> - 2013-03-26 09:18 -0400
csiph-web