<!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> </FONT>
<BR><FONT SIZE=2> ...from which I infer that Context exists in part to limit/round</FONT>
<BR><FONT SIZE=2> calculated results. Even if it were possible for me, as a user of</FONT>
<BR><FONT SIZE=2> Decimal, to set Context appropriately to achieve these ends, what</FONT>
<BR><FONT SIZE=2> if I use a library that also changes Context? The integrity of my</FONT>
<BR><FONT SIZE=2> calculations may be impacted.</FONT>
<BR><FONT SIZE=2> </FONT>
<BR><FONT SIZE=2>Aahz:</FONT>
</P>
<P><FONT SIZE=2> That's correct. There needs to be a social convention that libraries</FONT>
<BR><FONT SIZE=2> intended for use by other people *CANNOT* muck with Context, and if they</FONT>
<BR><FONT SIZE=2> do so for their own internal calculations, they must save and restore</FONT>
<BR><FONT SIZE=2> Context. You can probably find additional information about this in</FONT>
<BR><FONT SIZE=2> Cowlishaw.</FONT>
</P>
<P><FONT SIZE=2>Emile van Sebille:</FONT>
</P>
<P><FONT SIZE=2> Enter the context stack.</FONT>
</P>
<P><FONT SIZE=2>Aahz:</FONT>
</P>
<P><FONT SIZE=2> Well, sure. And it won't be hard to add given that Decimal will already</FONT>
<BR><FONT SIZE=2> need to track thread-specific Context. But modules changing Context</FONT>
<BR><FONT SIZE=2> will still need to explicitly push and pop Context because usually you</FONT>
<BR><FONT SIZE=2> will just want to replace the current Context.</FONT>
</P>
<P><FONT SIZE=2>Tim Peters:</FONT>
</P>
<P><FONT SIZE=2> They have another choice, because Guido had a brilliant idea: the</FONT>
<BR><FONT SIZE=2> arithmetic operations in Eric's implementation are methods *of* a context</FONT>
<BR><FONT SIZE=2> object (because Guido suggested that). So a maximally robust library</FONT>
<BR><FONT SIZE=2> doesn't *have* to change the thread context at all: it can create whatever</FONT>
<BR><FONT SIZE=2> private context object(s) it needs, and spell arithmetic as explicit method</FONT>
<BR><FONT SIZE=2> calls on its private context object(s), so that the default thread context</FONT>
<BR><FONT SIZE=2> object is neither consulted nor modified. This is very robust, and in small</FONT>
<BR><FONT SIZE=2> 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>. Facundo</FONT>
</P>
<BR>
<BR>
<BR>
<BR>
<P><B><FONT SIZE=2>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .</FONT></B></P>
<P><B><U><FONT SIZE=2>ADVERTENCIA </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>