changeset: 93442:4480506137ed user: Raymond Hettinger date: Sun Nov 09 15:56:33 2014 -0800 files: Doc/howto/logging-cookbook.rst Doc/library/pickle.rst Lib/_strptime.py Lib/asyncore.py Lib/ipaddress.py Lib/mailbox.py Lib/sre_compile.py Lib/sre_parse.py Lib/statistics.py Parser/asdl.py description: Issue #22823: Use set literals instead of creating a set from a list diff -r ec81edc30221 -r 4480506137ed Doc/howto/logging-cookbook.rst --- a/Doc/howto/logging-cookbook.rst Sat Nov 08 22:41:00 2014 +0200 +++ b/Doc/howto/logging-cookbook.rst Sun Nov 09 15:56:33 2014 -0800 @@ -1680,7 +1680,7 @@ def main(): logging.basicConfig(level=logging.INFO, format='%(message)s') - logging.info(_('message 1', set_value=set([1, 2, 3]), snowman='\u2603')) + logging.info(_('message 1', set_value={1, 2, 3}, snowman='\u2603')) if __name__ == '__main__': main() diff -r ec81edc30221 -r 4480506137ed Doc/library/pickle.rst --- a/Doc/library/pickle.rst Sat Nov 08 22:41:00 2014 +0200 +++ b/Doc/library/pickle.rst Sun Nov 09 15:56:33 2014 -0800 @@ -859,7 +859,7 @@ data = { 'a': [1, 2.0, 3, 4+6j], 'b': ("character string", b"byte string"), - 'c': set([None, True, False]) + 'c': {None, True, False} } with open('data.pickle', 'wb') as f: diff -r ec81edc30221 -r 4480506137ed Lib/_strptime.py --- a/Lib/_strptime.py Sat Nov 08 22:41:00 2014 +0200 +++ b/Lib/_strptime.py Sun Nov 09 15:56:33 2014 -0800 @@ -167,9 +167,9 @@ time.tzset() except AttributeError: pass - no_saving = frozenset(["utc", "gmt", time.tzname[0].lower()]) + no_saving = frozenset({"utc", "gmt", time.tzname[0].lower()}) if time.daylight: - has_saving = frozenset([time.tzname[1].lower()]) + has_saving = frozenset({time.tzname[1].lower()}) else: has_saving = frozenset() self.timezone = (no_saving, has_saving) diff -r ec81edc30221 -r 4480506137ed Lib/asyncore.py --- a/Lib/asyncore.py Sat Nov 08 22:41:00 2014 +0200 +++ b/Lib/asyncore.py Sun Nov 09 15:56:33 2014 -0800 @@ -57,8 +57,8 @@ ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, \ errorcode -_DISCONNECTED = frozenset((ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE, - EBADF)) +_DISCONNECTED = frozenset({ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE, + EBADF}) try: socket_map @@ -220,7 +220,7 @@ connecting = False closing = False addr = None - ignore_log_types = frozenset(['warning']) + ignore_log_types = frozenset({'warning'}) def __init__(self, sock=None, map=None): if map is None: diff -r ec81edc30221 -r 4480506137ed Lib/ipaddress.py --- a/Lib/ipaddress.py Sat Nov 08 22:41:00 2014 +0200 +++ b/Lib/ipaddress.py Sun Nov 09 15:56:33 2014 -0800 @@ -1088,7 +1088,7 @@ _DECIMAL_DIGITS = frozenset('0123456789') # the valid octets for host and netmasks. only useful for IPv4. - _valid_mask_octets = frozenset((255, 254, 252, 248, 240, 224, 192, 128, 0)) + _valid_mask_octets = frozenset({255, 254, 252, 248, 240, 224, 192, 128, 0}) _max_prefixlen = IPV4LENGTH # There are only a handful of valid v4 netmasks, so we cache them all diff -r ec81edc30221 -r 4480506137ed Lib/mailbox.py --- a/Lib/mailbox.py Sat Nov 08 22:41:00 2014 +0200 +++ b/Lib/mailbox.py Sun Nov 09 15:56:33 2014 -0800 @@ -1230,8 +1230,8 @@ class Babyl(_singlefileMailbox): """An Rmail-style Babyl mailbox.""" - _special_labels = frozenset(('unseen', 'deleted', 'filed', 'answered', - 'forwarded', 'edited', 'resent')) + _special_labels = frozenset({'unseen', 'deleted', 'filed', 'answered', + 'forwarded', 'edited', 'resent'}) def __init__(self, path, factory=None, create=True): """Initialize a Babyl mailbox.""" diff -r ec81edc30221 -r 4480506137ed Lib/sre_compile.py --- a/Lib/sre_compile.py Sat Nov 08 22:41:00 2014 +0200 +++ b/Lib/sre_compile.py Sun Nov 09 15:56:33 2014 -0800 @@ -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} def _compile(code, pattern, flags): # internal: compile a (sub)pattern diff -r ec81edc30221 -r 4480506137ed Lib/sre_parse.py --- a/Lib/sre_parse.py Sat Nov 08 22:41:00 2014 +0200 +++ b/Lib/sre_parse.py Sun Nov 09 15:56:33 2014 -0800 @@ -25,8 +25,8 @@ WHITESPACE = frozenset(" \t\n\r\v\f") -_REPEATCODES = frozenset((MIN_REPEAT, MAX_REPEAT)) -_UNITCODES = frozenset((ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY)) +_REPEATCODES = frozenset({MIN_REPEAT, MAX_REPEAT}) +_UNITCODES = frozenset({ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY}) ESCAPES = { r"\a": (LITERAL, ord("\a")), diff -r ec81edc30221 -r 4480506137ed Lib/statistics.py --- a/Lib/statistics.py Sat Nov 08 22:41:00 2014 +0200 +++ b/Lib/statistics.py Sun Nov 09 15:56:33 2014 -0800 @@ -150,7 +150,7 @@ # We fail as soon as we reach a value that is not an int or the type of # the first value which is not an int. E.g. _sum([int, int, float, int]) # is okay, but sum([int, int, float, Fraction]) is not. - allowed_types = set([int, type(start)]) + allowed_types = {int, type(start)} n, d = _exact_ratio(start) partials = {d: n} # map {denominator: sum of numerators} # Micro-optimizations. @@ -168,7 +168,7 @@ assert allowed_types.pop() is int T = int else: - T = (allowed_types - set([int])).pop() + T = (allowed_types - {int}).pop() if None in partials: assert issubclass(T, (float, Decimal)) assert not math.isfinite(partials[None]) diff -r ec81edc30221 -r 4480506137ed Parser/asdl.py --- a/Parser/asdl.py Sat Nov 08 22:41:00 2014 +0200 +++ b/Parser/asdl.py Sun Nov 09 15:56:33 2014 -0800 @@ -33,8 +33,7 @@ # See the EBNF at the top of the file to understand the logical connection # between the various node types. -builtin_types = set( - ['identifier', 'string', 'bytes', 'int', 'object', 'singleton']) +builtin_types = {'identifier', 'string', 'bytes', 'int', 'object', 'singleton'} class AST: def __repr__(self):