##// END OF EJS Templates
cborutil: port to Python 3...
Augie Fackler -
r37915:2ae6a313 default
parent child Browse files
Show More
@@ -140,12 +140,15 b' def streamencodearrayfromiter(it):'
140 140
141 141 yield BREAK
142 142
143 def _mixedtypesortkey(v):
144 return type(v).__name__, v
145
143 146 def streamencodeset(s):
144 147 # https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml defines
145 148 # semantic tag 258 for finite sets.
146 149 yield encodelength(MAJOR_TYPE_SEMANTIC, 258)
147 150
148 for chunk in streamencodearray(sorted(s)):
151 for chunk in streamencodearray(sorted(s, key=_mixedtypesortkey)):
149 152 yield chunk
150 153
151 154 def streamencodemap(d):
@@ -155,7 +158,8 b' def streamencodemap(d):'
155 158 """
156 159 yield encodelength(MAJOR_TYPE_MAP, len(d))
157 160
158 for key, value in sorted(d.iteritems()):
161 for key, value in sorted(d.iteritems(),
162 key=lambda x: _mixedtypesortkey(x[0])):
159 163 for chunk in streamencode(key):
160 164 yield chunk
161 165 for chunk in streamencode(value):
General Comments 0
You need to be logged in to leave comments. Login now