Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix up is vs == to match Python3 semantics
The python3 compiler does constant folding so that when it sees the same constant in source code. This confused me when I was doing some simple tests with the REPL where >>> (1,2) is (1,2) True but >>> a = (1,2) >>> b = (1,2) >>> a is b False Stick the latter in a file and it *also* gets True as the compiler does whole-file constant folding. So, here's my understanding of 'is' vs '==': is: Tuples and lists: object comparison, not contents Strings: content comparisons == Content comparisons, using == on each element of the list/tuple, so it recurses down the data structure. I've fixed the test to force Python3 to generate unique tuples even when compiled from a single file so that the results match snek, which doesn't manage to share tuples. Signed-off-by: Keith Packard <keithp@keithp.com>
- Loading branch information
1 parent
6de3d64
commit c03d6bb
Showing
4 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters