| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Add the :c:func:`Py_Is(x, y) <Py_Is>` function to test if the *x* object is the | ||
| *y* object, the same as ``x is y`` in Python. Add also the :c:func:`Py_IsNone`, | ||
| :c:func:`Py_IsTrue`, :c:func:`Py_IsFalse` functions to test if an object is, | ||
| respectively, the ``None`` singleton, the ``True`` singleton or the ``False`` | ||
| singleton. | ||
| Patch by Victor Stinner. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -2279,6 +2279,33 @@ Py_XNewRef(PyObject *obj) | |
| return _Py_XNewRef(obj); | ||
| } | ||
|
|
||
| #undef Py_Is | ||
| #undef Py_IsNone | ||
| #undef Py_IsTrue | ||
| #undef Py_IsFalse | ||
|
|
||
| // Export Py_Is(), Py_IsNone(), Py_IsTrue(), Py_IsFalse() as regular functions | ||
|
Comment thread
Outdated
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI am not super conviced. Why would people would like to use Py_Is if is going to be slower than just pointer comparison?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe intent is correctness if you care about other Python implelentations than CPython. If you don't care, well, don't use it :-)
Sorry, something went wrong.
All reactions
|
||
| // for the stable ABI. | ||
| int Py_Is(PyObject *x, PyObject *y) | ||
| { | ||
| return (x == y); | ||
| } | ||
|
|
||
| int Py_IsNone(PyObject *x) | ||
| { | ||
| return Py_Is(x, Py_None); | ||
| } | ||
|
|
||
| int Py_IsTrue(PyObject *x) | ||
| { | ||
| return Py_Is(x, Py_True); | ||
| } | ||
|
|
||
| int Py_IsFalse(PyObject *x) | ||
| { | ||
| return Py_Is(x, Py_False); | ||
| } | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.