We're stuck in the Dark Ages (Python 2.1) for the
moment on our
database server, but we really admire your
fixedpoint.py, which
as released appears to require Python 2.2 or above.
It seems to work just fine (well at least it passes
self-test)
against both python2.1 and python2.2 with the following
changes:
--- fixedpoint.py 17 Oct 2002 00:33:31 -0000 1.1
+++ fixedpoint.py 18 Oct 2002 00:01:34 -0000 1.3
@@ -152,12 +152,11 @@
# decimal point. This only has effect at compile-time.
DEFAULT_PRECISION = 2
-class FixedPoint(object):
+class FixedPoint:
"""Basic FixedPoint object class,
The exact value is self.n / 10**self.p;
self.n is a long; self.p is an int
"""
- __slots__ = ['n', 'p']
def __init__(self, value=0,
precision=DEFAULT_PRECISION):
self.n = self.p = 0
self.set_precision(precision)
@@ -277,8 +276,6 @@
elif p < self.p:
self.n = self._roundquotient(self.n,
_tento(self.p - p))
self.p = p
-
- precision = property(get_precision, set_precision)
def __str__(self):
n, p = self.n, self.p
I don't see anything in the documented interface that
appears to my
novice eyes to rely on the excised features, and I'm
wondering if you'd be willing to put up a
backward-compatible version of this class, or to bless
our fumble-fingered work with faint praise or at least
with only moderate scorn.
Thanks!
Dan WIlder <dan@ssc.com>
Mike Orr <mso@ssc.com>
Logged In: YES
user_id=6399
The original purpose of this project was to prepare
FixedPoint for inclusion in the Python 2.3 Standard Library.
So I assumed we could go hog-wild with the latest 2.2 features.
However, the real purpose of FixedPoint is to provide
useable code to developers. I have to admit that there is no
pressing need to derive FixedPoint from object, or to make
precision a property.
I'm undecided on this one. I'm going to post a question on
comp.lang.python and see what the community thinks.
Logged In: YES
user_id=113328
Couldn't you do something conditional, like:
if sys.version_info < (2,2):
class object:
pass
def property(get, set):
return None
This would effectively dummy out the object base class and
the property call... __slots__ just becomes a (useless)
normal instance variable pre-2.2.