mirror of
https://github.com/satwikkansal/wtfpython
synced 2024-11-24 03:54:25 +01:00
remove lineskip and bolden string interning in contents.md
This commit is contained in:
parent
28fa624a88
commit
c84b5169d8
1
README.md
vendored
1
README.md
vendored
@ -195,7 +195,6 @@ False
|
|||||||
Makes sense, right?
|
Makes sense, right?
|
||||||
|
|
||||||
#### 💡 Explanatios:
|
#### 💡 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.
|
+ 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.
|
+ 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).
|
+ After being interned, many variables may point to the same string object in memory (thereby saving memory).
|
||||||
|
2
wtfpython-pypi/content.md
vendored
2
wtfpython-pypi/content.md
vendored
@ -555,7 +555,7 @@ False
|
|||||||
Makes sense, right?
|
Makes sense, right?
|
||||||
|
|
||||||
#### 💡 Explanation:
|
#### 💡 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.
|
+ 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).
|
+ 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:
|
+ 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:
|
||||||
|
Loading…
Reference in New Issue
Block a user