1
0
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:
Jonathan H 2018-02-25 18:00:39 +00:00
parent 28fa624a88
commit c84b5169d8
2 changed files with 1 additions and 2 deletions

1
README.md vendored
View File

@ -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).

View File

@ -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: