Eric: I suspect he's talking about section 7.1.12.1 of the 6th edition of ECMA-262; a PDF can be found here: http://www.ecma-international.org/ecma-262/6.0/ECMA-262.pdf. Clause 6 applies to this particular example:
"""
If k <= n <= 21, return the String consisting of the code units of the k digits of the decimal representation of s (in order, with no leading zeroes), followed by nk occurrences of the code unit 0x0030 (DIGIT ZERO).
"""
here 'k' is the number of significant digits in the shortest possible representation (i.e., the number of significant digits that Python's repr will use), and n is the "adjusted exponent" of the input (so k = 16 and n = 21 in this case, because 10**20 <= target_value < 10**21).
I'm not convinced of the importance / value of making Python's json implementation exactly correspond to that of Google's JS engine, though. For one thing, there's no spec: ECMA-262 isn't good enough, since (as noted in the spec), the least significant digit isn't necessarily defined by their requirements, so it's still perfectly possible for two JS implementations to both conform with the specification and still give different output strings. |