By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,907 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,907 IT Pros & Developers. It's quick & easy.

Number methods

P: n/a

I can't find any description of these. Most are obvious, but some
are not. Note that this is from the point of view of IMPLEMENTING
them, not USING them. Specifically:

Does Python use classic division (nb_divide) and inversion (nb_invert)
or are they entirely historical? Note that I can very easily provide
the latter.

Is there any documentation on the coercion function (nb_coerce)? It
seems to have unusual properties.

Thanks for any hints.
Regards,
Nick Maclaren.
Jan 17 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Nick Maclaren wrote:
I can't find any description of these. Most are obvious, but some
are not. Note that this is from the point of view of IMPLEMENTING
them, not USING them. Specifically:
The Python equivalents of these methods are described in the
reference manual:
http://docs.python.org/ref/numeric-types.html

More details can be founf in various PEPs:
http://www.python.org/dev/peps/
Does Python use classic division (nb_divide) and inversion (nb_invert)
or are they entirely historical? Note that I can very easily provide
the latter.
Python uses classic divison by default. True divison is used only when
the division __future__ directive is in effect. See PEP 238 for
details:
http://www.python.org/dev/peps/pep-0238/

The nb_invert method is used for the implementation of the bitwise
inverse unary operator (~). I don't think that it is deprecated. See:
http://docs.python.org/lib/bitstring-ops.html for details.
Is there any documentation on the coercion function (nb_coerce)? It
seems to have unusual properties.
It is used for old style Python classes and extension types that
don't have Py_TPFLAGS_CHECKTYPES in their tp_flags. See:
http://docs.python.org/ref/coercion-rules.html
and
http://www.python.org/dev/peps/pep-0208/
for details.

Ziga

Jan 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.