summaryrefslogtreecommitdiffstats
path: root/Objects/bytes_methods.c
diff options
context:
space:
mode:
authorEddie Elizondo <eduardo.elizondorueda@gmail.com>2023-04-22 19:39:37 (GMT)
committerGitHub <noreply@github.com>2023-04-22 19:39:37 (GMT)
commitea2c0016502472aa8baa3149050ada776d17a009 (patch)
treee9e3935a9b71a1f88ac18c24fe512d199880ff90 /Objects/bytes_methods.c
parent916de04fd1838530096336aadb3b94b774ed6c90 (diff)
downloadcpython-ea2c0016502472aa8baa3149050ada776d17a009.zip
cpython-ea2c0016502472aa8baa3149050ada776d17a009.tar.gz
cpython-ea2c0016502472aa8baa3149050ada776d17a009.tar.bz2
gh-84436: Implement Immortal Objects (gh-19474)
This is the implementation of PEP683 Motivation: The PR introduces the ability to immortalize instances in CPython which bypasses reference counting. Tagging objects as immortal allows up to skip certain operations when we know that the object will be around for the entire execution of the runtime. Note that this by itself will bring a performance regression to the runtime due to the extra reference count checks. However, this brings the ability of having truly immutable objects that are useful in other contexts such as immutable data sharing between sub-interpreters.
Diffstat (limited to 'Objects/bytes_methods.c')
-rw-r--r--Objects/bytes_methods.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
index ef9e65e..33aa9c3 100644
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -258,9 +258,12 @@ _Py_bytes_istitle(const char *cptr, Py_ssize_t len)
const unsigned char *e;
int cased, previous_is_cased;
- /* Shortcut for single character strings */
- if (len == 1)
- return PyBool_FromLong(Py_ISUPPER(*p));
+ if (len == 1) {
+ if (Py_ISUPPER(*p)) {
+ Py_RETURN_TRUE;
+ }
+ Py_RETURN_FALSE;
+ }
/* Special case for empty strings */
if (len == 0)