GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing peps.python.org — PEP 228 – Reworking Python’s Numeric Model | peps.python.org
PEP 228 – Reworking Python’s Numeric Model
PEP 228 – Reworking Python’s Numeric Model
WithdrawalThis PEP has been withdrawn in favor of PEP 3141. AbstractToday, Python’s numerical model is similar to the C numeric model:
there are several unrelated numerical types, and when operations
between numerical types are requested, coercions happen. While
the C rationale for the numerical model is that it is very similar
to what happens at the hardware level, that rationale does not
apply to Python. So, while it is acceptable to C programmers that
NOTE: in the light of recent discussions in the newsgroup, the motivation in this PEP (and details) need to be extended. RationaleIn usability studies, one of the least usable aspect of Python was
the fact that integer division returns the floor of the division.
This makes it hard to program correctly, requiring casts to
Other Numerical ModelsPerl’s numerical model is that there is one type of numbers – floating point numbers. While it is consistent and superficially non-surprising, it tends to have subtle gotchas. One of these is that printing numbers is very tricky, and requires correct rounding. In Perl, there is also a mode where all numbers are integers. This mode also has its share of problems, which arise from the fact that there is not even an approximate way of dividing numbers and getting meaningful answers. Suggested Interface For Python’s Numerical ModelWhile coercion rules will remain for add-on types and classes, the built in type system will have exactly one Python type – a number. There are several things which can be considered “number methods”:
Obviously, a number which answers true to a question from 1 to 5, will
also answer true to any following question. If Now, there is two thing the models promises for the field operations
(
One consequence of these two rules is that all exact calculations are done as (complex) rationals: since the field laws must hold, then (a/b)*b == a must hold. There is built-in function, Several of the classical Python functions will return exact numbers
even when given inexact numbers: e.g, CoercionThe number type does not define Inexact OperationsThe functions in the Numerical Python IssuesPeople who use Numerical Python do so for high-performance vector operations. Therefore, NumPy should keep its hardware based numeric model. Unresolved IssuesWhich number literals will be exact, and which inexact? How do we deal with IEEE 754 operations? (probably, isnan/isinf should be methods) On 64-bit machines, comparisons between ints and floats may be broken when the comparison involves conversion to float. Ditto for comparisons between longs and floats. This can be dealt with by avoiding the conversion to float. (Due to Andrew Koenig.) CopyrightThis document has been placed in the public domain. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |