<div class="gmail_quote">On Tue, Mar 25, 2008 at 11:29 AM, Nick Coghlan &lt;<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="Wj3C7c">I thought that might be what happened, but I couldn&#39;t remember if that<br></div></div>
optimisation was a 2.6 only change or not (I suspect it was included in<br>
2.5 as a prereq to the spec compliance updates).<br></blockquote><div><br></div><div>Exactly.</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Anyway, +1 on coercing the mantissa to a str() instance in 2.5.<br>
<br>
This does raise an interesting point though - currently Decimal in Py3k<br>
is storing the mantissa as a Unicode instance instead of a bytes<br>
instance. The performance implications of that are horrendous since<br>
PyLong_FromUnicode does a malloc, encodes the string into the malloced<br>
buffer, then invokes PyLong_FromString on the result.<br></blockquote><div><br></div><div>Urk! &nbsp;Yes, this definitely needs to be looked at.</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The following is also a problem in Py3k:<br>
[...]<br><br>
The isinstance(value, str) check in Py3k is too restrictive - it needs<br>
to accept bytes instances as well.<br></blockquote><div><br></div><div>I don&#39;t understand this.&nbsp;Why does Decimal.__new__ need to accept</div><div>bytes instances? &nbsp;Isn&#39;t it just supposed&nbsp;to be creating a Decimal</div>
<div>from a string? &nbsp;Or is the idea that it should&nbsp;accept ASCII strings</div><div>that are masquerading as bytes instances, for&nbsp;reasons of</div><div>convenience/efficiency/something else?</div><div><br></div><div>Unicode/bytes/str and encoding issues frighten me much more than<br>
</div><div>floating-point arithmetic ever did, so I expect I&#39;m missing many<br></div><div>things here.</div><div><br></div><div>Mark</div></div>