Class infinity
object --+
|
infinity
The infinity object possess the algebraic properties necessary for use
as a bound on semi-infinite and infinite segments.
This class uses comparison-by-identity rather than
comparison-by-value. What this means, is there are only ever two
instances of this class, representing positive and negative infinity
respectively. All other "instances" of this class are infact
simply references to one of these two, and comparisons are done by
checking which one you've got. This improves speed and reduces memory
use, and is similar in implementation to Python's boolean True and False
objects.
The normal way to obtain references to positive or negative infinity
is to do infinity() or -infinity() respectively. It is also possible to
select the sign by passing a single numeric argument to the constructor.
The sign of the argument causes a reference to either positive or
negative infinity to be returned, respectively. For example infinity(-1)
is equivalent to -infinity(). However, this feature is a little slower
and not recommended for normal use; it is provided only to simplify the
pickling and unpickling of instances of the class.
Example:
>>> x = infinity()
>>> x > 0
True
>>> x + 10 == x
True
>>> segment(-10, 10) - segment(-x, 0)
segment(0, 10)
>>> import math
>>> math.isinf(x)
True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
a new object with type S, a subtype of T
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__init__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
Inherited from object :
__class__
|
__hash__(x)
(Hashing function)
|
|
hash(x)
- Overrides:
object.__hash__
|
- Returns: a new object with type S, a subtype of T
- Overrides:
object.__new__
|
Pickle support
- Overrides:
object.__reduce__
|
__repr__(x)
(Representation operator)
|
|
repr(x)
- Overrides:
object.__repr__
|
__str__(x)
(Informal representation operator)
|
|
str(x)
- Overrides:
object.__str__
|