<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>RE: [Python-Dev] PEP 327: Decimal Data Type</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Michael Chermside wrote:</FONT>
</P>

<P><FONT SIZE=2>#- Imagine the following senario. I write some code which uses</FONT>
<BR><FONT SIZE=2>#- Decimal, and which sets the context to get the desired rounding</FONT>
<BR><FONT SIZE=2>#- behavior. Somewhere in my code I call a routine written by</FONT>
<BR><FONT SIZE=2>#- somebody else... perhaps some library code... which also does</FONT>
<BR><FONT SIZE=2>#- some calculations using Decimal.</FONT>
</P>

<P><FONT SIZE=2>This subject already has been discussed in c.l.p:</FONT>
</P>
<BR>

<P><FONT SIZE=2>Emile van Sebille:</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; ...from which I infer that Context exists in part to limit/round</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; calculated results.&nbsp; Even if it were possible for me, as a user of</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; Decimal, to set Context appropriately to achieve these ends, what</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; if I use a library that also changes Context?&nbsp; The integrity of my</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; calculations may be impacted.</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>Aahz:</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; That's correct.&nbsp; There needs to be a social convention that libraries</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; intended for use by other people *CANNOT* muck with Context, and if they</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; do so for their own internal calculations, they must save and restore</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; Context.&nbsp; You can probably find additional information about this in</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; Cowlishaw.</FONT>
</P>

<P><FONT SIZE=2>Emile van Sebille:</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; Enter the context stack.</FONT>
</P>

<P><FONT SIZE=2>Aahz:</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; Well, sure.&nbsp; And it won't be hard to add given that Decimal will already</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; need to track thread-specific Context.&nbsp; But modules changing Context</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; will still need to explicitly push and pop Context because usually you</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; will just want to replace the current Context.</FONT>
</P>

<P><FONT SIZE=2>Tim Peters:</FONT>
</P>

<P><FONT SIZE=2>&nbsp;&nbsp;&nbsp; They have another choice, because Guido had a brilliant idea:&nbsp; the</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; arithmetic operations in Eric's implementation are methods *of* a context</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; object (because Guido suggested that).&nbsp; So a maximally robust library</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; doesn't *have* to change the thread context at all:&nbsp; it can create whatever</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; private context object(s) it needs, and spell arithmetic as explicit method</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; calls on its private context object(s), so that the default thread context</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; object is neither consulted nor modified.&nbsp; This is very robust, and in small</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; doses is quite bearable.</FONT>
</P>
<BR>

<P><FONT SIZE=2>I don't have any problem to implement a context stack. But I think that it's no clear to be useful, so I think it's better to go for the sure staff, and when Decimal gets heavy use, if everybody agrees to add a context stack, we'll go for it.</FONT></P>

<P><FONT SIZE=2>What do you think?</FONT>
</P>

<P><FONT SIZE=2>.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Facundo</FONT>
</P>
<BR>
<BR>
<BR>
<BR>

<P><B><FONT SIZE=2>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .</FONT></B></P>

<P><B><U><FONT SIZE=2>ADVERTENCIA&nbsp;</FONT></U> </B>
</P>

<P><B><FONT SIZE=2>La información contenida en este mensaje y cualquier archivo anexo al mismo, son para uso exclusivo del destinatario y pueden contener información confidencial o propietaria, cuya divulgación es sancionada por la ley. </FONT></B></P>

<P><B><FONT SIZE=2>Si Ud. No es uno de los destinatarios consignados o la persona responsable de hacer llegar este mensaje a los destinatarios consignados, no está autorizado a divulgar, copiar, distribuir o retener información (o parte de ella) contenida en este mensaje. Por favor notifíquenos respondiendo al remitente, borre el mensaje original y borre las copias (impresas o grabadas en cualquier medio magnético) que pueda haber realizado del mismo. </FONT></B></P>

<P><B><FONT SIZE=2>Todas las opiniones contenidas en este mail son propias del autor del mensaje y no necesariamente coinciden con las de Telefónica Comunicaciones Personales S.A. o alguna empresa asociada. </FONT></B></P>

<P><B><FONT SIZE=2>Los mensajes electrónicos pueden ser alterados, motivo por el cual Telefónica Comunicaciones Personales S.A. no aceptará ninguna obligación cualquiera sea el resultante de este mensaje. </FONT></B></P>

<P><B><FONT SIZE=2>Muchas Gracias.</FONT></B>
</P>

</BODY>
</HTML>