[issue46187] Optionally support rounding for math.isqrt()

2022-01-01 Thread Case Van Horsen
Case Van Horsen added the comment: FWIW, gmpy2 uses isqrt_rem. Of course, gmpy2 uses underscores a lot. And uses next_toward instead of nextafter, and copy_sign instead of copysign, and is_nan instead of isnan... :( I would keep the math module consistent and use isqrtrem. I'll look

[issue40604] Regression in 3.8.3rc1 - error in tests run via doctest

2020-05-12 Thread Case Van Horsen
New submission from Case Van Horsen : An error in the gmpy2 test suite was reported at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=960201 The test suite is run using doctest and has been running without issues for many years. The first failure occurs when running the following

[issue29882] Add an efficient popcount method for integers

2017-03-23 Thread Case Van Horsen
Case Van Horsen added the comment: I like the name bit_count and I'll gladly add it to gmpy2 with the appropriate changes to exceptions, etc. -- nosy: +casevh ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue29160] pow with three int arguments works like it had two arguments

2017-01-04 Thread Case Van Horsen
Case Van Horsen added the comment: This is a bug/limitation in numpy. If x and y are Python integers, and type(z) is of another numeric type, pow calls the nb_power slot of the underlying type. Here a quick example using numpy.int32 and gmpy2.mpz: >>> import numpy, gmpy2 >>&

[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-09 Thread Case Van Horsen
Case Van Horsen added the comment: I ran the mpmath test suite with the fastint6 and fastint5_4 patches. fastint6 results without gmpy: 0.25% faster with gmpy: 3% slower fastint5_4 results without gmpy: 1.5% slower with gmpy: 5.5% slower

[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-08 Thread Case Van Horsen
Case Van Horsen added the comment: mpmath is a library for arbitrary-precision floating-point arithmetic. It uses Python's native long type or gmpy2's mpz type for computations. It is available at https://pypi.python.org/pypi/mpmath. The test suite can be run directly from the source tree

[issue21955] ceval.c: implement fast path for integers with a single digit

2016-02-07 Thread Case Van Horsen
Case Van Horsen added the comment: Can I suggest the mpmath test suite as a good benchmark? I've used it to test the various optimizations in gmpy2 and it has always been a valuable real-world benchmark. And it is slower in Python 3 than Python 2

[issue4709] Mingw-w64 and python on windows x64

2015-05-19 Thread Case Van Horsen
Changes by Case Van Horsen cas...@gmail.com: -- nosy: +casevh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4709 ___ ___ Python-bugs-list mailing

[issue22198] Odd floor-division corner case

2014-09-22 Thread Case Van Horsen
Changes by Case Van Horsen cas...@gmail.com: -- nosy: +casevh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22198 ___ ___ Python-bugs-list mailing

[issue22444] Floor divide should return int

2014-09-20 Thread Case Van Horsen
Case Van Horsen added the comment: Does Scheme's default integer type support arbitrarily large values? Yes, at least is does on the version I tested. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444

[issue22444] Floor divide should return int

2014-09-20 Thread Case Van Horsen
Case Van Horsen added the comment: What are the use-cases for float // float where integer result is not acceptable? It can lead to unexpected memory consumption when dealing with arbitrary precision values. What should Decimal('1e123456')//1 return? The result is exactly equal to Decimal

[issue22444] Floor divide should return int

2014-09-20 Thread Case Van Horsen
Case Van Horsen added the comment: On Sat, Sep 20, 2014 at 9:38 AM, Alexander Belopolsky rep...@bugs.python.org wrote: Alexander Belopolsky added the comment: Perhaps it's worth mentioning that several people on Python-ideas took the opposite view: math.floor() should return a float. I

[issue22444] Floor divide should return int

2014-09-20 Thread Case Van Horsen
Case Van Horsen added the comment: What should Decimal('1e123456')//1 return? I think Decimal case should be considered separately. Note that unlike float, they are not part of the numerical tower, so PEP 3141 arguments don't apply: isinstance(1.0, numbers.Real) True isinstance

[issue22444] Floor divide should return int

2014-09-19 Thread Case Van Horsen
Changes by Case Van Horsen cas...@gmail.com: -- nosy: +casevh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22444 ___ ___ Python-bugs-list mailing

[issue21955] ceval.c: implement fast path for integers with a single digit

2014-07-16 Thread Case Van Horsen
Changes by Case Van Horsen cas...@gmail.com: -- nosy: +casevh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21955 ___ ___ Python-bugs-list mailing

[issue21922] PyLong: use GMP

2014-07-14 Thread Case Van Horsen
Case Van Horsen added the comment: I've successfully tested the patch. The patch works fine but there are a couple of issues: 1) The patch relies on several new low-level functions that were introduced in the latest release of GMP 6.0.0. Most Linux distributions are still providing older

[issue21922] PyLong: use GMP

2014-07-12 Thread Case Van Horsen
Changes by Case Van Horsen cas...@gmail.com: -- nosy: +casevh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21922 ___ ___ Python-bugs-list mailing

[issue21922] PyLong: use GMP

2014-07-12 Thread Case Van Horsen
Case Van Horsen added the comment: Disclaimer: as Mark alluded to, I maintain gmpy2. Some comments on MPIR/GMP: For all practical purposes, building GMP on Windows requires some version of the mingw compiler toolchain. None of the performance gains of custom assembly code is available if GMP

[issue16483] Make int(float('inf')) raise ValueError rather than OverflowError.

2012-11-15 Thread Case Van Horsen
Case Van Horsen added the comment: I agree that ValueError is a more correct exception but I also don't think OverflowError is all that wrong. I don't think the change is worth the risk of breaking existing code. I'd be fine with either option. -- nosy: +casevh

[issue16469] Exceptions raised by Fraction() different from those raised by int()

2012-11-14 Thread Case Van Horsen
Case Van Horsen added the comment: Do we also want to change int(infinity) to return ValueError? I think consistent behavior between int() and Fraction() is valuable. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16469

[issue16469] Exceptions raised by Fraction() from those raised by int()

2012-11-13 Thread Case Van Horsen
New submission from Case Van Horsen: When attempting to convert a float(nan), float(inf), or float(-inf), fractions.Fraction() raises different exceptions than int() int(float(nan)) Traceback (most recent call last): File stdin, line 1, in module ValueError: cannot convert float NaN

[issue7652] Merge C version of decimal into py3k.

2012-03-07 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I've found some differences between decimal and cdecimal. cdecimal 2.3 does not support the __ceil__ and __floor__ methods that exist in decimal. math.ceil converts a cdecimal.Decimal instance into a float before finding the ceiling

Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-08 Thread Case Van Horsen
On Tue, Feb 7, 2012 at 9:37 PM, Alec Taylor alec.tayl...@gmail.com wrote: Thanks all for your replies. I have now installed MSVC8 and YASM. I assume you installed Visual Studio. I've omitted the commands to use the SDK compiler below. I was able to successfully run configure.bat and make.bat

Re: PyCrypto builds neither with MSVC nor MinGW

2012-02-08 Thread Case Van Horsen
into that DLL. Only the innvocation of setup.py should need to refer to the MPIR library locations. I don't use pip so I'm not sure how to get pip to install the resulting DLL, etc. On Wed, Feb 8, 2012 at 9:48 PM, Case Van Horsen cas...@gmail.com wrote: On Tue, Feb 7, 2012 at 9:37 PM, Alec Taylor

[issue11395] print(s) fails on Windows with long strings

2011-03-03 Thread Case Van Horsen
New submission from Case Van Horsen cas...@gmail.com: Python 3.2 fails when printing long strings. C:\Python32python Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. print(a*66000) Traceback (most

[issue11247] Error sending packets to multicast IPV4 address

2011-02-18 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I tested multicast without any issues using the attached script. I used RC3 on both Windows 7 and Linux. I did need to disable the firewall on my Windows system before multicast would work. Start one or more clients using: python mtest1.py

[issue7652] Merge C version of decimal into py3k.

2010-11-02 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: Has the cdecimal branch kept up with the hash value changes in 3.2? Is there a still a chance that cdecimal could be merged into 3.2? -- nosy: +casevh ___ Python tracker rep...@bugs.python.org http

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-10-23 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: On Win64, I get two unexpected failures: I terminated test_capi after a Windows exception box popped up. [ 37/349] test_capi test test_capi failed -- Traceback (most recent call last): File C:\svn\py3k\lib\test\test_capi.py, line 50

[issue10185] Py_hash_t declaration needed in _testcapimodule

2010-10-23 Thread Case Van Horsen
New submission from Case Van Horsen cas...@gmail.com: While researching errors in issue 9778, I found a variable in _testcapimodule.c that should be declared Py_hash_t instead of long. Patch is attached. -- components: Interpreter Core files: py_hash_t_testcapimodule.diff keywords

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-10-22 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I maintain gmpy and it needs to calculate hash values for integers, floats, and rationals. I converted my hash calculations to use Py_ssize_t in a 64-bit Windows enviroment. All my tests pass when I build Python with my previous patch

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-10-22 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I've uploaded a patch against the current svn trunk that: 1) Defines a Py_uhash_t as equivalent to size_t. 2) Correctly defines _PyHASH_MODULUS on Win64. 3) Replaces several PyLong_FromLong with PyLong_FromSsize_t. 4) Change typeobject

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-10-21 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I've attached a patch that fixes hashing for numerical types, sys.hash_info is now correct, fixes typeobject.c/wrap_hashfunc and tupleobject.c/tuplehash to use Py_ssize_t instead of long, and uses Py_ssize_t instead of Py_hash_t. I think

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-10-18 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: Some quick comments on the latest patch. 1) I don't think you can remove the type cast used when comparing the hash value against -1 and -2. IIRC, GCC considers that undefined behavior. 2) In sysmodule.c, we need to use PyLong_FromSsize_t

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-10-18 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: Also, note that hash(-12) is -12. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9778

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-10-18 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: Sorry, I could have been clearer indeed. Consider the following code: static Py_hash_t long_hash(PyLongObject *v) { unsigned long x; ... x = x * sign; if (x == (unsigned long)-1) x = (unsigned long)-2; return

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-10-17 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I'm the maintainer of a third-party library (gmpy) that would be impacted by this and I'm definately in favor of this change. With ever increasing amounts of memory becoming standard in computers, more users will encounter performance issues

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-10-17 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: The patch does not address that unsigned long is still used to calculate the hash values. This breaks numeric hashing and leads to incorrect values. Python 3.2a3+ (py3k, Oct 17 2010, 19:03:38) [MSC v.1500 64 bit (AMD64)] on win32 Type help

[issue9778] Make hash values the same width as a pointer (or Py_ssize_t)

2010-09-05 Thread Case Van Horsen
Changes by Case Van Horsen cas...@gmail.com: -- nosy: +casevh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9778 ___ ___ Python-bugs-list mailing

[issue9739] Output of help(...) is wider than 80 characters

2010-09-05 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I edited the doc string for math.modf since an indent of 8 spaces is used for the doc string with help(math). An indent of 4 spaces is used with help(math.modf). I've attached a new patch for just the math module that includes the return

[issue9739] Output of help(...) is wider than 80 characters

2010-09-02 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: According to PEP 7, the first line of the doc string should contain the signature of the function, then there should be a blank line, and then the rest of the doc string. There may be tools that extract the signature line. The patch just

[issue9739] Output of help(...) is wider than 80 characters

2010-09-01 Thread Case Van Horsen
New submission from Case Van Horsen cas...@gmail.com: In several modules, the output of help(some_module) is wider than 80 characters. This results in extra line wrapping and incorrect formatting of the help text. I've attached a single patch (doc_width1.diff) that corrects the issue

[issue8188] Unified hash for numeric types.

2010-04-20 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I've spent some time working through the new hash function by re-implementing it for gmpy. Very elegant design. I like _PyHASH_MODULUS better, too. Regarding a hash function for complex types, I think documenting the existing behavior

[issue7767] Add PyLong_AsLongLongAndOverflow

2010-01-29 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: The missing PyInt_Check is a mistake. I probably thought I was working on a py3k version. Let me know if I should create a new patch or if I should create one for py3k. Thanks for the review

[issue7767] Add PyLong_AsLongLongAndOverflow

2010-01-23 Thread Case Van Horsen
New submission from Case Van Horsen cas...@gmail.com: There are Long and LongLong variants for most of the C API functions that work with PyLong. This patch adds a LongLong version of PyLong_AsLongAndOverflow. This function will be helpful on 64-bit Windows platforms to quickly get a 64-bit

[issue7528] Provide PyLong_AsLongAndOverflow compatibility to Python 2.x

2009-12-20 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I will work on documentation and test case patches. Per comments on python-dev, there doesn't appear to be interest in distributing forward compatibility files. I will update the bug report with a slightly revised version of py3intcompat.c

[issue7528] Provide PyLong_AsLongAndOverflow compatibility to Python 2.x

2009-12-20 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I uploaded a new consolidated diff that includes the original patch with (hopefully) correct whitespace, some tests, and doc updates. The test just verifies that overflow is set/cleared properly. Proper conversions to long are already tested

[issue7528] Provide PyLong_AsLongAndOverflow compatibility to Python 2.x

2009-12-17 Thread Case Van Horsen
New submission from Case Van Horsen cas...@gmail.com: When I ported gmpy to Python 3.x, I began to use PyLong_AsLongAndOverflow frequently. I found the code to slightly faster and cleaner than using PyLong_AsLong and checking for overflow. I had several code fragments that looked like

[issue7528] Provide PyLong_AsLongAndOverflow compatibility to Python 2.x

2009-12-17 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: Attached py3intcompat.c -- Added file: http://bugs.python.org/file15579/py3intcompat.c ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7528

[issue7528] Provide PyLong_AsLongAndOverflow compatibility to Python 2.x

2009-12-17 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I don't want it to be a 2.7-only feature. I'm trying to maintain compatibility with 2.4 and later for gmpy. I would be in favor with adding it to 2.7 as long as we could still provide a standalone version for earlier releases of Python. I

[issue7528] Provide PyLong_AsLongAndOverflow compatibility to Python 2.x

2009-12-17 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I uploaded a patch to add PyLong_AsLongAndOverflow. It was made against the 2.7a1 source. make test, gmpy's test suite, and mpmath's test suite all pass. Let me know if there is anything else I can do. -- keywords: +patch Added file

[issue7528] Provide PyLong_AsLongAndOverflow compatibility to Python 2.x

2009-12-17 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: Uploaded a new version of py3intcompat.c. It should be save to include with any version of Python, included 2.7 with PyLong_AsLongAndOverflow added. The file includes basic documentation on use. -- Added file: http://bugs.python.org

[issue7414] Format code C is missing from skipitem() in getargs.c

2009-11-30 Thread Case Van Horsen
New submission from Case Van Horsen cas...@gmail.com: An error was reported on c.l.py. The following code in a Python 3 extension module generated an error: = If I use the following C code static PyObject* foo(PyObject *self, PyObject *args, PyObject *kwrds

[issue6431] Fraction fails equality test with a user-defined type

2009-07-16 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: On Thu, Jul 16, 2009 at 11:34 AM, Mark Dickinsonrep...@bugs.python.org wrote: Mark Dickinson dicki...@gmail.com added the comment: Thanks again, casevh!  The patch looks good.  I've added to it a bit, though---see issue6431.patch

[issue6431] Fraction fails equality test with a user-defined type

2009-07-15 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: I've attached a patch that creates DummyRational and then tests comparisons between Fraction and DummyRational. The __eq__ method also verifies that the type of the other argument is fractions.Fraction. -- Added file: http

[issue6431] Fraction fails equality test with a user-defined type

2009-07-07 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: On Tue, Jul 7, 2009 at 1:26 AM, Mark Dickinsonrep...@bugs.python.org wrote: Mark Dickinson dicki...@gmail.com added the comment: I agree this should be fixed.  The conversion to float in the else clause seems wrong to me: it can lose

[issue6431] Fraction fails equality test with a user-defined type

2009-07-07 Thread Case Van Horsen
Case Van Horsen cas...@gmail.com added the comment: Change Fraction __eq__ method to give the other operand a chance to perform the comparison if Fraction doesn't understand the other operand. -- keywords: +patch Added file: http://bugs.python.org/file14470/fractions_patch.diff

[issue6431] Fraction fails equality test with a user-defined type

2009-07-06 Thread Case Van Horsen
New submission from Case Van Horsen cas...@gmail.com: I've ported the GMPY module to Python 3 and found a problem comparing Fraction to gmpy.mpq. mpq is the rational type in gmpy and knows how to convert a Fraction into an mpq. All operations appear to work properly except Fraction == mpq. mpq