FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-29878: Add global instances of int for 0 and 1. by serhiy-storchaka · Pull Request #852 · python/cpython · GitHub

/ cpython Public

bpo-29878: Add global instances of int for 0 and 1. - #852

Merged
serhiy-storchaka merged 2 commits into
python:masterfrom
serhiy-storchaka:long-constants
Mar 30, 2017
Merged

bpo-29878: Add global instances of int for 0 and 1.#852
serhiy-storchaka merged 2 commits into
python:masterfrom
serhiy-storchaka:long-constants

Conversation

Copy link
Copy Markdown
Member

For internal use only.

Copy link
Copy Markdown

@serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @tiran, @ncoghlan and @benjaminp to be potential reviewers.

mdickinson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm really happy to see all these code go away! It's painful to have to check for errors on obvious things like that numbers 0 and 1!

The overall change LGTM, but IMHO it would be safer to use Py_CLEAR() in PyLong_Fini(). I have propose a minor coding style change.

Comment thread Objects/longobject.c
return -1;
}
*pdiv = (PyLongObject*)_PyLong_Zero;
Py_INCREF(_PyLong_Zero);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Whenever possible, even if we are protected by the GIL, I prefer to have Py_INCREF before assignement, for consistency.

Comment thread Objects/longobject.c Outdated
needed, but Python must forget about the reference or multiple
reinitializations will fail. */
Py_DECREF(_PyLong_One);
Py_DECREF(_PyLong_Zero);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Py_CLEAR() would be safer if PyLong_Init() is called again (Py_Initialized called multiple times), no?

Comment thread Objects/rangeobject.c Outdated
return NULL;
}
start = _PyLong_Zero;
Py_INCREF(start);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

ditto, in general I prefer to start with INCREF.

serhiy-storchaka merged commit ba85d69 into python:master Mar 30, 2017
serhiy-storchaka deleted the long-constants branch March 30, 2017 06:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL