This issue also exists as: https://sourceforge.net/apps/trac/pyxb/ticket/91

Based on a very quick review of the comments in that ticket, as well as the
original discussion that it references, it is unlikely that the base type
underlying the decimal type in PyXB will change because there seem to be a
couple incompatibilities between Python decimal and XML Schema decimal,
including the effect of significant digits and lack of support for certain
operators.

I'd have to spend some time analyzing all that to determine what the
correct change would be, informed by how people actually use xs:decimal as
opposed to xs:float.  It might be something to revisit if/when there's a
Python3 update to PyXB, but don't count on it happening spontaneously any
time soon.

Peter


On Tue, Mar 12, 2013 at 8:28 PM, Nathan Robertson <nath...@nathanr.net>wrote:

> Hi,
>
> I was just looking at the PyXB API documentation. Is there any difference
> in the PyXB implementation of xsd:float from xsd:decimal? Looking at:
>
> http://pyxb.sourceforge.net/api/pyxb.binding.datatypes.decimal-class.html
>
> it says that it inherits from the Python float type, which is an IEEE
> binary floating point number. The XML Schema specification says that
> xsd:float should be a 32 bit IEEE floating point number, but it seems stops
> short on defining xsd:decimal as arbitrary precision - it just says at
> least 18 decimal digits must be supported. But it is certainly true that
> the way they define and describe xsd:float vs. xsd:decimal are quite
> different.
>
> (http://www.w3.org/TR/xmlschema-2/#decimal)
>
> I note in the PyXB documentation it says:
>
> "*To Do:* The Python base type for this is wrong. Consider
> http://code.google.com/p/mpmath/";.
>
> Is there any reason why the base python type shouldn't just be the built
> in decimal type? From what I gather, this is arbitrary precision. As a
> point of note, JAXB uses java.lang.BigDecimal (arbitrary precision floating
> point number) for xsd:decimal.
>
> Traditionally, we (as in, at my workplace) have used xsd:decimal for
> monetary values in our XML documents, and obviously want to ensure that
> under no circumstances these get rounded. I'm thinking of changing all the
> types in my XML schema to xsd:string to avoid this type mapping issue, and
> manually converting the string to an arbitrary precision decimal type
> (probably the inbuilt python decimal type). But before I do that, is there
> any chance that the type that PyXB uses can be or will be changed from
> being based on an IEEE floating point number (with it's rounding and
> precision issues) to an arbitrary precision decimal type of some sort?
> Doing so seems to make sense - if the user really wants IEEE floating
> point, xsd:float is the XML Schema type for that. And the documentation
> seems to suggest that this was the thinking, at least at some point in the
> past.
>
> Or am I missing something here?
>
> Regards,
> Nathan.
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> pyxb-users mailing list
> pyxb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyxb-users
>
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
pyxb-users mailing list
pyxb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyxb-users

Reply via email to