Patchwork [09,of,18,helps-py3] util: move from dict() construction to {} literals

login
register
mail settings
Submitter Augie Fackler
Date March 12, 2014, 5:40 p.m.
Message ID <0916f829eb8d0b2bf1d5.1394646043@augie-macbookair>
Download mbox | patch
Permalink /patch/3917/
State Superseded
Commit 0916f829eb8d0b2bf1d5e8037f55c72b964a9006
Headers show

Comments

Augie Fackler - March 12, 2014, 5:40 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1394644760 14400
#      Wed Mar 12 13:19:20 2014 -0400
# Node ID 0916f829eb8d0b2bf1d5e8037f55c72b964a9006
# Parent  da6bea33007b0002e8e4a20b259e0964cefbefbb
util: move from dict() construction to {} literals

The latter are both faster and more consistent across Python 2 and 3.

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1198,11 +1198,11 @@ 
     """
 
     def lower(date):
-        d = dict(mb="1", d="1")
+        d = {'mb': "1", 'd': "1"}
         return parsedate(date, extendeddateformats, d)[0]
 
     def upper(date):
-        d = dict(mb="12", HI="23", M="59", S="59")
+        d = {'mb': "12", 'HI': "23", 'M': "59", 'S': "59"}
         for days in ("31", "30", "29"):
             try:
                 d["d"] = days