There are many places where the old-style of creating a set from a list still persists. The literal notation is idiomatic, cleaner looking, and faster.
Here's a typical change:
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -22,10 +22,10 @@
else:
MAXCODE = 0xFFFFFFFF
-_LITERAL_CODES = set([LITERAL, NOT_LITERAL])
-_REPEATING_CODES = set([REPEAT, MIN_REPEAT, MAX_REPEAT])
-_SUCCESS_CODES = set([SUCCESS, FAILURE])
-_ASSERT_CODES = set([ASSERT, ASSERT_NOT])
+_LITERAL_CODES = {LITERAL, NOT_LITERAL}
+_REPEATING_CODES = {REPEAT, MIN_REPEAT, MAX_REPEAT}
+_SUCCESS_CODES = {SUCCESS, FAILURE}
+_ASSERT_CODES = {ASSERT, ASSERT_NOT}
Here are typical timings:
$ py34 -m timeit '{10, 20, 30}'
10000000 loops, best of 3: 0.145 usec per loop
$ py34 -m timeit 'set([10, 20, 30])'
1000000 loops, best of 3: 0.477 usec per loop |