On Thursday, October 25, 2012 7:56:25 AM UTC-7, Charles Hixson wrote:
> In Python3 is there any good way to count the number of on bits in an
> integer (after an & operation)?
You may want to look at gmpy2[1] and the popcount() function.
>
> Alternatively, is there any VERY light-weight impleme
n include optimized assembler for the CPU you're using. But
> I guess it needs more memory. Hence disk-swapping could be an issue
> on performance.
>
gmpy will be faster than Python as the numbers get larger. The cutover varies
depending on the platform, but usually occurs between 50 and 100 digits.
casevh
>
> --gv
--
http://mail.python.org/mailman/listinfo/python-list
cluded in gmpy's source download. I would
try to build MPIR and gmpy first and then adapt/modify the process for
PyCrypto.
MPIR home page: www.mpir.org
gmpy source: gmpy.googlecode.com/files/gmpy-1.15.zip
> doesn't even MinGW install PyCrypto for me?
>
> Thanks for all sugge
ot;python setup.py install" was successful. I created a
binary installer with "python setup.py bdist-wininst".
There may be a cleaner way to build PyCrypto, but these steps worked for me.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
isqrt() returns an "mpz".
As part of the documentation for the beta release, I will document the name
changes. "import gmpy2 as gmpy; gmpy.scan0=gmpy.bit_scan0; etc" should work
just fine.
If you encounter problems with the alpha release, please open an issue on
gmpy's
ise Python exceptions when exceptional events
occur with MPFR arithmetic; for example, comparing
against "nan" can trigger an exception
* more complete coverage for MPFR
* many function names were changed to be more consistent
Please report any issues!
casevh
--
http://mail.python.org/mailman/listinfo/python-list
ino Laser GmbH
> Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932- Hide
> quoted text -
>
> - Show quoted text -
A quick search on the Python issue tracker (bugs.python.org) yields
the following issues:
http://bugs.python.org/issue560379
http://bugs.python.org/issue4258
The issues also refer to discussion threads on the python-dev mailing
list.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
roof only asserts that sum(1/k^2) is between
the upper and lower partial sums. The upper and lower partial sums
both converge to pi^2/6 from below and since the sum(1/k^2) is between
the two partial sums, it must also converge to pi^2/6.
Try calculating sum(1/k^2) for k in range(1, 2**n)
2, I implemented the nb_inplace_add
function and performance (for the gmpy.mpz type) is much better for
the in-place addition.
For the adventuresome, gmpy2 implements a mutable integer type called
xmpz. It isn't much faster until the values are so large that the
memory copy times become significant
1.1
> 1.2102
> >>> print (1.1 * 1.1)
> 1.2102
> >>> print(repr((1.1 * 1.1)))
> 1.2102
>
> >>> '{:g}'.format(1.1 * 1.1)
> '1.21'
>
I get same results as you do for Python 3.1.4 and 3.2.2. IIRC, Python
3.2 changed (for floats) __str__ to call __repr__. That should explain
the difference between 3.1.4 and 3.2.2
Also note that 1.1 * 1.1 is not the same as 1.21.
>>> (1.1 * 1.1).as_integer_ratio()
(5449355549118301, 4503599627370496)
>>> (1.21).as_integer_ratio()
(1362338887279575, 1125899906842624)
This doesn't explain why 2.7.2 displayed a different result on your
computer. What do you get for as_integer_ratio() for (1.1 * 1.1) and
(1.21)?
casevh
> jmf
--
http://mail.python.org/mailman/listinfo/python-list
decrease the
overhead for gmpy operations. The breakeven point for older versions
will be higher so if you are running performance critical code with
older versions of gmpy, I'd recommend upgrading to 1.14.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
I downloaded and tried the CVS version. Division still didn't work as
expected.
>>> import gmpy
>>> gmpy.version()
'1.01'
>>> gmpy.mpz(9)//gmpy.mpz(4)
Traceback (most recent call last):
File "", line 1, in ?
TypeError: unsupported operand type(s) for //: 'mpz' and 'mpz'
>>> from __future__ impor
Everything works fine with v1.16. I'm sure I was doing something wrong.
I shouldn't be testing that late at night. ;-)
It looks like the warning about "tp_compare" has been fixed.
I will try to build a version for Windows, but that may take me a day
or two.
Thanks for the updates to gmpy!
Case
Alex Martelli wrote:
> <[EMAIL PROTECTED]> wrote:
>
> > Everything works fine with v1.16. I'm sure I was doing something wrong.
> > I shouldn't be testing that late at night. ;-)
> >
> > It looks like the warning about "tp_compare" has been fixed.
>
> I didn't touch tp_compare specifically, so the
> > Will you be updating the information in setup.py file?
>
> Done, in the current CVS version.
I will grab the CVS version and create installers.
> > Which versions of Python do you want to support?
>
> I have tested gmpy with 2.3 and 2.4 on Mac, and those two and also 2.2
> on Linux. I think
I've created Windows binaries for Python 2.3 and 2.4. It should be
compatible with PentiumPro or later processors.
They can be found at http://home.comcast.net/~casevh/
Case
--
http://mail.python.org/mailman/listinfo/python-list
.
An early alpha-quality release is available at
http://home.comcast.net/~casevh/
I also have release candidate versions of GMPY for Windows on that
page.
I'll try to get the next release and some demos up in a few days.
Case
--
http://mail.python.org/mailman/listinfo/python-list
Already done for next version. Tentatively, there will be a package
called "ar" (Arbitrary Radix) and the module will be called BigInt. I'm
also working on an arbitrary radix BigFloat module.
Case
--
http://mail.python.org/mailman/listinfo/python-list
Paul Rubin wrote:
> [EMAIL PROTECTED] (Alex Martelli) writes:
> > As the author of gmpy, I'd like to point out that the speed difference
> > isn't all that large, if all you're doing is ordinary arithmetic -- a
> > few times at most (it can be better if you need some of GMP's
> > functionality whi
What processor are you running?
I only have Windows running on an old Pentium 3. It is easy for me to
build a version that will running on almost any recent processor. I'm
willing to try and override the CPU detection and make a processor
specific build for you. I won't be able to test it, though.
tim wrote:
> trying to work with a directory in windows, that has "\a" in the full
> pathname
>
> this works:
>
> >>> c = string.replace('c:\content\ce\cw\cvd', '\\', '\\')
> >>> c
> 'c:\\content\\ce\\cw\\cvd'
>
> this doesn't:
>
> >>> c = string.replace('c:\content\a\a\avd', '\\', '\\')
> >>>
16x slower than GMP but can actually
be faster in some instances; for example, dividing a 2,000,000 digit
number by an 800,000 digit number.
DecInt can be found at http://home.comcast.net/~casevh/
(DecInt used to be called BigDecimal; I renamed it to avoid confusion
with the "decimal"
DecInt's division algorithm is completely general also. But I would
never claim that Python code is faster than assembler. I believe that
careful implementation of a good algorithm is more important than the
raw speed of the language or efficiency of the compiler. Python makes
it easy to implement
Madhu R. Vajrala wrote:
>
> 2. gunzip -c Python-2.4.1.tgz | tar xvf -
>
Use gtar. The Solaris tar does not hnadle long file names correctly.
gtar should be found in /usr/sfw/bin.
cvh
--
http://mail.python.org/mailman/listinfo/python-list
With the round-trip time of 245ms, three seconds only allows for
approximately 12 packet exchanges (roughly 24 total packets). I think
latency is your problem.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
James Stroud wrote:
> On Friday 25 March 2005 08:39 am, Ivan Van Laningham wrote:
> > As far as grouping by indentation goes, it's why I fell in love
with
> > Python in the first place. Braces and so on are just extraneous
cruft
> > as far as I'm concerned. It's the difference between Vietnamese
st native Python long support, the division algorithm is faster
than the built-in division algorithm when the numbers are several tens
of thousands digits long.
Interestingly, BigDecimal can do division faster than GMP 3.1.x with
numbers approximately 10 million digits in length. BigDecimal is fas
k.
>
> TIA
> Dan
The following example will divide two integers with a result precision
of 1024 bits:
import gmpy2
# Set mpfr precision to 1024
gmpy2.get_context().precision=1024
# Omitting code
a = gmpy2.mpz(SML)/gmpy2.mpz(x)
Python 3.x performs true division by default. When integer division involves
an mpz, the result will be an mpfr with the precision of the current context.
Does this help?
casevh
--
https://mail.python.org/mailman/listinfo/python-list
code.google.com/p/gmpy/ ) module?
It supports all the transcendental function available in the MPFR library. I
did a quick performance test of sqrt() and ln() at around 1000 decimal digits.
gmpy2 was about ~200 times faster than the corresponding functions in decimal.
casevh
--
https://mail.python.org/mailman/listinfo/python-list
writing it in C I would suppose).
IIRC, cdecimal uses a Number Theory Transform for multiplication of very large
numbers. It has been a while since I looked so I could be wrong.
casevh
--
https://mail.python.org/mailman/listinfo/python-list
function or something similar.
> There is also another library http://pypi.python.org/pypi/bitarray
> which resembles numpy's bit array.
>
> Hope it helps,
> S.Nizamov
You can also use gmpy or gmpy2.
>>> a=gmpy2.mpz(123)
>>> bin(a)
'0b011'
&g
ed at
http://home.comcast.net/~casevh
Enjoy,
casevh
--
http://mail.python.org/mailman/listinfo/python-list
You have two calls to reTest and so reTest needs to return twice. One
return is from the reTest(True) call back to reTest(False). The second
return is from reTest(False) back to the prompt.
What were you expecting to happen?
--
http://mail.python.org/mailman/listinfo/python-list
I don't know of a way to directly access the internal structure of a
long, but you can speed up your example.
First, is the order of the commands
> i=i>>1
> lstBitsBitwiseAnd.append(i&0x01)
what you intend? The first low order bit is discarded because you've
done the shift first. And an extr
I've built it with both GCC and Sun Studio compilers.
Try adding /usr/sfw/bin to your path.
Or set CC=/usr/sfw/bin/gcc
casevh
--
http://mail.python.org/mailman/listinfo/python-list
It looks like it is finding c++ in /usr/local/bin. Is that the compiler
you want to use?
I was assuming you want to use the Sun provided GCC located in
/usr/sfw/bin.
Try
CC=/usr/sfw/bin/gcc CXX=/usr/sfw/bin/g++ ./configure
casevh
--
http://mail.python.org/mailman/listinfo/python-list
apes the values so they can be displayed.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
; the customer" using print "%20.2f", then there will be a cent missing
> here and there... why not smooth out that imperfection and return that
> penny to the customer? (not that they really care).
The decimal module will do what you want. One of its primary
motivations was correct rounding for financial activities.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
negative
> integers it seems to subtract one from the expected result.
>
That is the intended behavior. Look at the output of divmod().
>>> divmod(-1,100)
(-1,99)
Let (q,r) = divmod(d, v) with v > 0, the behavior is chosen so that 0<=
r < v.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
related tools.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
> And who can confirm that these modules are independent of Python version?
> Gmpy
I've compiled gmpy for Python 2.5. It is available at
http://home.comcast.net/~casevh/
> (tip: I am on windows, and I don't can/know compile any module)
casevh
--
http://mail.python.o
ompiled Python 2.5 successfully on 32-bit Intel platform. After
running configure, I had to manually edit the generated Makefile to add
the contents of CFLAGS.
I've had difficulties with ctypes, too. To get a successful compile, I
had to edit ffitarget.h (I think) and also use the Sun Studio Express 2
compiler suite. Or use gcc.
>
> thanks,
> martijn
casevh
--
http://mail.python.org/mailman/listinfo/python-list
specially since I havent got MS visual studio...
> and mingw is not supported... :-(
mingw32 is supported and can compile many extensions. See the following
post:
http://groups.google.com/group/comp.lang.python/msg/8e2260fe4d4b7de9
If you meant something else with your comment, please expl
ecessary...
I've used mingw32 to build gmpy for Python 2.5 without any problems. It
looks like mingw32 works just fine with Python 2.5 (assuming the
extension will compile with mingw32).
casevh
--
http://mail.python.org/mailman/listinfo/python-list
>
> The link for pexports-0.42h.zip is broken so I cant
> test it on an extension.
>
pexports is only needed for Python 2.3. It is not required for 2.4 or
2.5.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
32-bit platform.
I just compiled GMP 4.2.1 on a P4 using
$ CFLAGS="" CC=gcc ./configure
$ gmake; gmake check
and all tests passed.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
32-bit platform.
I just compiled GMP 4.2.1 on a P4 using
$ CFLAGS="" CC=gcc ./configure
$ gmake; gmake check
and all tests passed.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
ly compiled GMP 4.2.1 on Solaris 10 x86 using both the
> GCC and Sun Studio compilers on AMD 32-bit platform.
>
> I just compiled GMP 4.2.1 on a P4 using
>
> $ CFLAGS="" CC=gcc ./configure
> $ gmake; gmake check
>
You must use "gmake". "make" fails during "make check"
> and all tests passed.
>
> casevh
--
http://mail.python.org/mailman/listinfo/python-list
> PAolo
Use mingw32. It should work fine for most extensions.
For example, see
http://groups.google.com/group/comp.lang.python/msg/8e2260fe4d4b7de9
and the followup messages.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
re CFLAGS, for example, so I just
edited Makefile to suit my environment. You should set the values
appropriate for you system, of course.
I've also compiled Python using the Sun Studio compiler. Some tests
were faster, some tests were slower.
casevh
--
> http://chrismiles.info/
--
http://mail.python.org/mailman/listinfo/python-list
t 28 seconds)
> whereas
> b = str(a) takes forever!
>
> Regards
> Sreeram
>
If you really want all 3,440,299 digits, use the DecInt module..
http://home.comcast.net/~casevh/
Using Python 2.4.3 on a 1.4Ghz Celeron, a=DecInt(34564323) ** 456356
takes 20 seconds. astr=str(a) takes j
hing syntax is trying to achieve. I haven't been able
> to find any answer of on the google web and groups.
>
> TIA.
@function_name is called a decorator.
http://www.python.org/dev/peps/pep-0318/
http://docs.python.org/whatsnew/node6.html
casevh
--
http://mail.python.org/mailman/listinfo/python-list
ath
>>> 200 * 1024 * 1024 * 15 * math.log10(2)
946958486.2000643
Since memory space is required for temporary storage of intermediate
results, you won't actually be able to create a number that large if
you only have 400 megabytes.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
GMPY binaries for Python 2.5 are available at
http://home.comcast.net/~casevh/
Notes
They have not been extensively tested.
This is based on the CVS version of gmpy and includes a patch (not yet
in CVS) from Alex Martelli that resolves a bug with divm(). Please
consider this an "unoff
d the subject line to read "Python 2.5" instead of "Windows
2.5".
Wasn't Windows 2.5 the result of running Windows 3.11 on a 386sx
processor? ;-)
Thanks for stirring up old memories. I wonder where my 3.11 disks are?
casevh
--
http://mail.python.org/mailman/listinfo/python-list
> > Notes
> >
> > They have not been extensively tested.
>
> They don't work. At least the Pentium4 binary doesn't work,
> same problem as before. Is the patch installed?
I found the problem. Updated binaries should be available in a couple
of hours. I'll add a note to the web page. I tested
> 1. Get MinGW gcc and/or g++, preferably via MinGW installer from [1].
> You may have to restart your computer or manually edit PATH system
> environment variable to include MinGW's bin directory (default is
> c:\mingw\bin). Then check if it is there by typing `path` in the cmd
> window.
1a. [Opt
me way to avoid importing
> from __future__ in module after module?
Start python with the "-Qnew" option.
>
> Thanks,
> Alan Isaac
casevh
--
http://mail.python.org/mailman/listinfo/python-list
> PS Any news on when true division will be the default?
Python 3.0 (aka P3K). It is the release that can break backwards
compatibility.
http://www.python.org/dev/peps/pep-3000/
casevh
--
http://mail.python.org/mailman/listinfo/python-list
r/bin/python /usr/lib/python2.4/idlelib/idle.py
casevh
--
http://mail.python.org/mailman/listinfo/python-list
n. Solaris Express ( stable
development snapshots, usually released every two weeks or so) provide
Python 2.4 as /usr/bin/python.
I would try to use the python executable located in /usr/bin if it is
exists, otherwise use the python executable in /usr/sfw/bin.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
you'll need.
You could try uninstalling the bittorrent client and reinstalling a
client with all its required dependencies.
HTH,
casevh
--
http://mail.python.org/mailman/listinfo/python-list
econds. I tried a couple of optimizations but
couldn't make any more improvements.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
7; % (e + h))
e = i
return ''.join(result)
start_time = clock()
pi = pi()
print pi
print "Total time elapsed:", round(clock() - start_time, 2), "s"
print len(pi)
casevh
--
http://mail.python.org/mailman/listinfo/python-list
> Yes, this "gmpy" sounds good for calc things like that.
> But not available on my machine.
> ImportError: No module named gmpy
What type of machine?
The home page for gmpy is http://sourceforge.net/projects/gmpy/
I have Windows versions available at http://home.comcast.n
rbt wrote:
> I've been doing some file system benchmarking. In the process, I need to
> create a large file to copy around to various drives. I'm creating the
> file like this:
>
> fd = file('large_file.bin', 'wb')
> for x in xrange(40960):
> fd.write('0')
> fd.close()
>
> This takes a fe
Oops. I did mean
fd.write(block)
The only limit is available memory. I've used 1MB block sizes when I
did read/write tests. I was comparing NFS vs. local disk performance. I
know Python can do at least 100MB/sec.
--
http://mail.python.org/mailman/listinfo/python-list
On Ubuntu, I have tried 3.3.4, 3.4.3 and 4.0. Compile and make test ran
successfully with all three. For my benchmark, platform, and compiler
options, 3.4.3 was the fastest by approximately 2%.
I would normally use the default compiler for your distribution.
casevh
--
http://mail.python.org
oming from a corporate IT world, I'm not surprised
that it is not reasonably configured
casevh
--
http://mail.python.org/mailman/listinfo/python-list
p end here
> xx
> xx
> x
> < loop should end here
Assuming f is initialized as in your example, try
-
for s in f:
print s
-
casevh
--
http://mail.python.org/mailman/listinfo/python-list
offset += 1
if offset > end:
offset = 0
loops += 1
if not loops % 1: print loops
fh.close()
if __name__ == '__main__':
write_file(loops=150)
read_file()
casevh
--
http://mail.python.org/mailman/listinfo/python-list
maintainer) to fix a bug found by
mensanator. With Alex's permission, I released it as gmpy 1.04a. Alex
has not updated cvs with the fix.
gmpy 1.04a compiles cleanly with the latest releases of Python and
GMP, so I consider it stable.
>
> Actually, gmpy is being maitained even
.
Alex released versions 1.02 and 1.03 as CVS updates only. I think he
may have made an announcement that 1.02 included alpha support for
Python 2.5. 1.04a is 1.03 with one additional fix. I don't think there
has been an official release, though.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
x27;s interested in helping out is welcome to mail me and/or
> use the "wiki" and "issues" entry of the Google Code gmpy site...
>
> Thanks,
>
> Alex
I can keep building gmpy for Windows. I actually use MINGW since
getting GMP compiled under MSVC is "challanging". I should be able to
build new binaries for Windows this weekend. And I would be happy to
point everyone to a real release.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
py are you using? (What is
gmpy.version()?)
I just compiled Alex's most recent SVN version on Linux without any
problems. I'll make Windows binaries next.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
window size
> have something to do with it?
>
> Paul
Tuning the TCP window size will make a big difference with Windows XP
performance. I'm more curious about the original script. Either the
test was against the loopback address, or he has a very impressive
netork to sustain 1.8Gbit/s.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
= Decimal(1)
> False
> >>> ((1.0/3.0)*3.0) == 1.0
>
> True
Try ((15.0/11.0)*11.0) == 15.0. Decimal is actually returning the
correct result. Your example was just lucky.
Decimal was intended to solve a different class of problems. It
provides predictable arithmetic using &qu
'd assume you are exceeding the precision available with standard
64-bit floating point. Here is a library for extended precision
floating point, including trig functions.
http://calcrpnpy.sourceforge.net/clnumManual.html
casevh
--
http://mail.python.org/mailman/listinfo/python-list
thmetic where the total number of bits by the
numerator and denominator was bounded. IIRC, a use case was matrix
inversion.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
e rationals and expect a constant running time.
There are trade-offs between IEEE-754 binary, Decimal, and Rational
arithmetic. They all have there appropriate problem domains.
And sometimes you just need unlimited precision, radix-6, fixed-point
arithmetic
casevh
--
http://mail.python.org/mailman/listinfo/python-list
mal (radix-10) number, 536/10
cannot be written exactly as a binary number. If you really need
decimal numbers, use the Decimal class.
See http://docs.python.org/tut/node16.html.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
> Tim
Take a look at gmpy and the is_power function. I think it will do
exactly what you want.
http://code.google.com/p/gmpy/
casevh
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 1, 1:04 pm, Mensanator wrote:
> On Feb 1, 2:27 am, casevh wrote:
>
> > On Jan 31, 9:36 pm, "Tim Roberts" wrote:
>
> > > Actually, all I'm interested in is whether the 100 digit numbers have an
> > > exact integral root, or not. At the
On Feb 1, 10:02 pm, Mensanator wrote:
> On Feb 1, 8:20 pm, casevh wrote:
>
>
>
> > On Feb 1, 1:04 pm, Mensanator wrote:
>
> > > On Feb 1, 2:27 am, casevh wrote:
>
> > > > On Jan 31, 9:36 pm, "Tim Roberts" wrote:
>
> > > > &
bits necessary to represent its argument in binary:"
>
> Any tips on how to get this in 2.5.2 as that's the production version
> I'm stuck with.
>
> Cheers,
>
> Jon.
If performance does become an issue, the newly released gmpy 1.04
includes bit_length().
casevh
--
http://mail.python.org/mailman/listinfo/python-list
to gmpy.mpz type failed
>
>
>
> Is this a bug in gmpy?
>
> If yes is there any way to issue the bug athttp://code.google.com/p/gmpy/
> without creating a gmail account?
I've added it for you.
>
> Thanks
>
> Martin
Thanks for reporting the issue.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
best of 3: 12.5 usec per loop
$ py31 -m timeit -s "a=int('23'*150);b=int('47'*150)" "c=a*b"
10 loops, best of 3: 3.13 usec per loop
$ py25 -m timeit -s "import gmpy;a=gmpy.mpz('23'*150);b=gmpy.mpz
('47'*150)" "c=a*b"
100 loops, best of 3: 0.673 usec per loop
Platform is 64-bit Linux with Core2 Duo processor. gmpy was linked
against MPIR 1.1. MPIR is an LGPLv2 fork of GMP and is significantly
faster than GMP 4.2.x. The newly released GMP 4.3.0 is about 10%
faster yet.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 21, 12:11 am, Paul Rubin <http://phr...@nospam.invalid> wrote:
> casevh writes:
> > Python 3.1 is significantly faster than Python 2.x on 64-bit
> > platforms. The following times are for multiplication with 2, 30 and
> > 300 decimal digits.
>
> Could yo
On Apr 21, 5:47 am, Paul Rubin <http://phr...@nospam.invalid> wrote:
> casevh writes:
> > > Could you test pow(a,b,c) where a,b,c are each 300 decimal digits?
>
> > $ py25 -m timeit -s "a=long('23'*150);b=long('47'*150);m=long
> > ('
On Apr 28, 5:39 pm, Li Wang wrote:
> 2009/4/29 Tim Chase :
>
> >> I want to concatenate two bits string together: say we have '1001' and
> >> '111' which are represented in integer. I want to concatenate them to
> >> '100' (also in integer form), my method is:
> >> ('1001' << 3) | 111
> >> whi
e. It uses Python
as it glue/scripting language. It includes support for MPFR, a
multiple-precision floating point library based on GMP. www.sagemath.org
casevh
--
http://mail.python.org/mailman/listinfo/python-list
; (I am new to Python)
>
> --
> Michael Press
GMPY provides the interface between Python and GMP. It is available at
http://code.google.com/p/gmpy/downloads/list
casevh
--
http://mail.python.org/mailman/listinfo/python-list
ry floating-point.
http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate
casevh
--
http://mail.python.org/mailman/listinfo/python-list
gt; text -
>
It's not a Python problem. That is just the behavior for floating-
point arithmetic.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
> No, I do not know that. Define desperate.
> Does Python support the extended Euclidean algorithm
> and other number theory functions?
No.
> How fast does Python multiply?
Python uses the Karatsuba algorithm which O(n^1.585). Division is
still O(n^2).
> Not that the latter is particularly impo
of
> no value.
gmpy is supported on Python 2.6. A new version and Windows binaries
were released shortly after 2.6b1 was released.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
nother!
>
> Thankyou.
Python's path is build by site.py. In the file /usr/lib/python2.5/
site.py, look for the line "prefixes.insert(0, '/usr/local')" and
comment it out. That should do it.
casevh
--
http://mail.python.org/mailman/listinfo/python-list
however
it is also used to force an existing number to match a new precision
setting. For example, using the decimal module:
>>> from decimal import *
>>> t=Decimal('1.23456')
>>> t
Decimal("1.23456")
>>> getcontext().prec = 5
>>> +t
Decimal("1.2346")
>
> Thanks for the feedback.
> --
> Ethan
casevh
--
http://mail.python.org/mailman/listinfo/python-list
>>> divmod(-9,2)
(-5, 1)
>>> divmod(9,2)
(4, 1)
casevh
--
http://mail.python.org/mailman/listinfo/python-list
operations. I plan to add a new
mutable integer type in the next release of GMPY. If you want to
experiment with mutable integers now, GMPY can be compiled with
mutable version of the standard 'mpz' type. Please see the file
"mutable_mpz.txt" for more information.
Please repor
1 - 100 of 143 matches
Mail list logo