From c84b5169d8872af232136314860e5d9bc0ca54fc Mon Sep 17 00:00:00 2001 From: Jonathan H Date: Sun, 25 Feb 2018 18:00:39 +0000 Subject: [PATCH] remove lineskip and bolden string interning in contents.md --- README.md | 1 - wtfpython-pypi/content.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 2481515..b649bd3 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,6 @@ False Makes sense, right? #### 💡 Explanatios: - + Such behavior is due to CPython optimization (called **string interning**) that tries to use existing immutable objects in some cases rather than creating a new object every time. + Note that the keyword `is` is used for _reference_ equality (unlike `==` which is used for _value_ equality); this means that `a is b` is the same as `id(a) == id(b)`, and therefore it should not be used for string comparison. It is only used here to illustrate the effects of string interning. + After being interned, many variables may point to the same string object in memory (thereby saving memory). diff --git a/wtfpython-pypi/content.md b/wtfpython-pypi/content.md index 70a9a95..ad35e0c 100644 --- a/wtfpython-pypi/content.md +++ b/wtfpython-pypi/content.md @@ -555,7 +555,7 @@ False Makes sense, right? #### 💡 Explanation: -+ Such behavior is due to CPython optimization (called string interning) that tries to use existing immutable objects in some cases rather than creating a new object every time. ++ Such behavior is due to CPython optimization (called **string interning**) that tries to use existing immutable objects in some cases rather than creating a new object every time. + Note that the keyword `is` is used for _reference_ equality (unlike `==` which is used for _value_ equality); this means that `a is b` is the same as `id(a) == id(b)`, and therefore it should not be used for string comparison. It is only used here to illustrate the effects of string interning. + After being interned, many variables may point to the same string object in memory (thereby saving memory). + In the snippets above, strings are implicitly interned. The decision of when to implicitly intern a string is implementation dependent. There are some facts that can be used to guess if a string will be interned or not: