[issue46311] Clean up PyLong_FromLong and PyLong_FromLongLong

2022-03-04 Thread Mark Shannon


Change by Mark Shannon :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46311] Clean up PyLong_FromLong and PyLong_FromLongLong

2022-03-01 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset c60e6b6ad7aaf9c72035ff9fb1575e2710aeb4b4 by Mark Dickinson in 
branch 'main':
bpo-46311: Clean up PyLong_FromLong and PyLong_FromLongLong (GH-30496)
https://github.com/python/cpython/commit/c60e6b6ad7aaf9c72035ff9fb1575e2710aeb4b4


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46311] Clean up PyLong_FromLong and PyLong_FromLongLong

2022-01-09 Thread Mark Dickinson


Change by Mark Dickinson :


--
keywords: +patch
pull_requests: +28705
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30496

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue46311] Clean up PyLong_FromLong and PyLong_FromLongLong

2022-01-09 Thread Mark Dickinson


New submission from Mark Dickinson :

PR GH-27832 inadvertently (I believe) introduced a couple of changes to 
PyLong_FromLong that didn't make a lot of sense: an (unsigned long) cast was 
replaced with (twodigits), and a digit count variable (counting number of 
PyLong digits in a C long) had its type needlessly changed from int to 
Py_ssize_t.

The first change is a potential portability bug, but only on platforms where 
the width of C's `long` exceeds 64 bits. The (unsigned long) cast is obviously 
correct, while figuring out whether (twodigits) loses information takes some 
work.

The second change is merely a potential pessimization: there's no need to use 
what's typically a 64-bit integer to count the number of PyLong digits in a 
long.

While fixing these, I've also reworked the PyLong_FromLong code a bit to move 
the medium int check earlier, and I've applied analogous changes to 
PyLong_FromLongLong.

--
messages: 410141
nosy: Mark.Shannon, mark.dickinson
priority: normal
severity: normal
status: open
title: Clean up PyLong_FromLong and PyLong_FromLongLong
versions: Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com