Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-01 Thread M.-A. Lemburg
Greg Ewing wrote: > Raymond Hettinger wrote: > >> I think this would harm more than it would help. It more confusing to >> have several rounding-thingies to choose from than it is have an >> explicit two-step. > > But is it more confusing enough to be worth forcing > everyone to pay two functi

Re: [Python-Dev] Which version of distutils to ship with Python 2.5?

2006-08-01 Thread M.-A. Lemburg
Martin v. Löwis wrote: > Anthony Baxter schrieb: >>> In any case, I bumped the version number to 2.5, according to the >>> policy discussed in >>> >> Could this not simply use the Python version number directly, instead? > > See the prior discussion at > > http://mail.python.org/pipermail/distuti

Re: [Python-Dev] Bad interaction of __index__ and sequence repeat

2006-08-01 Thread Nick Coghlan
Travis Oliphant wrote: >> Probably the most interesting thing now would be for Travis to review >> it, and see whether it makes things easier to handle for the Numeric >> scalar types (given the amount of code the patch deleted from the >> builtin and standard library data types, hopefully the b

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-01 Thread Greg Ewing
M.-A. Lemburg wrote: > I suppose you don't know about the optional argument > to round that lets you round up to a certain decimal ?! Yes, I know about, but I rarely if ever use it. Rounding a binary float to a number of decimal places seems a fundamentally ill-considered thing to do anyway. What

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-01 Thread M.-A. Lemburg
Greg Ewing wrote: > M.-A. Lemburg wrote: > >> I suppose you don't know about the optional argument >> to round that lets you round up to a certain decimal ?! > > Yes, I know about, but I rarely if ever use it. > Rounding a binary float to a number of decimal > places seems a fundamentally ill-con

Re: [Python-Dev] Rounding float to int directly ...

2006-08-01 Thread Nick Maclaren
"M.-A. Lemburg" <[EMAIL PROTECTED]> wrote: > > You often have a need for controlled rounding when doing > financial calculations or in situations where you want to > compare two floats with a given accuracy, e.g. to work > around rounding problems ;-) The latter is a crude hack, and was traditiona

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-01 Thread Aahz
On Tue, Aug 01, 2006, M.-A. Lemburg wrote: > > You often have a need for controlled rounding when doing financial > calculations or in situations where you want to compare two floats > with a given accuracy, e.g. to work around rounding problems ;-) > > The usual approach is to use full float accur

Re: [Python-Dev] Rounding float to int directly ...

2006-08-01 Thread Nick Maclaren
Aahz <[EMAIL PROTECTED]> wrote: > On Tue, Aug 01, 2006, M.-A. Lemburg wrote: > > > > You often have a need for controlled rounding when doing financial > > calculations or in situations where you want to compare two floats > > with a given accuracy, e.g. to work around rounding problems ;-) > > > >

Re: [Python-Dev] Rounding float to int directly ...

2006-08-01 Thread Raymond Hettinger
Nick Maclaren wrote: Well, maybe. There are other approaches, too, and Decimal has its problems with that. In particular, when people need precisely defined decimal rounding, they ALWAYS need fixed-point and not floating-point. The decimal spec was designed to encompass both floating-

Re: [Python-Dev] Rounding float to int directly ...

2006-08-01 Thread Nick Maclaren
Raymond Hettinger <[EMAIL PROTECTED]> wrote: > > Hogwash.  The only issues with decimal are ease-of-use and speed. I suggest that you get hold of a good 1960s or 1970s book on computer arithmetic, and read up about "wobbling precision". While it is not a big deal, it was regarded as such, and is

Re: [Python-Dev] Bad interaction of __index__ and sequence repeat

2006-08-01 Thread Nick Coghlan
Nick Coghlan wrote: > Travis Oliphant wrote: >>> Probably the most interesting thing now would be for Travis to review >>> it, and see whether it makes things easier to handle for the Numeric >>> scalar types (given the amount of code the patch deleted from the >>> builtin and standard library d

[Python-Dev] clock_gettime() vs. gettimeofday()?

2006-08-01 Thread skip
This has probably been discussed before, however ... Is there any reason to use clock_gettime() in preference to gettimeofday() if it exists? It pretends to at least return seconds + nanoseconds, where gettimeofday() returns seconds + microseconds. Are there perhaps some platforms where it's po

Re: [Python-Dev] Rounding float to int directly ...

2006-08-01 Thread Ron Adam
Nick Maclaren wrote: > "M.-A. Lemburg" <[EMAIL PROTECTED]> wrote: >> You often have a need for controlled rounding when doing >> financial calculations or in situations where you want to >> compare two floats with a given accuracy, e.g. to work >> around rounding problems ;-) > > The latter is a c

[Python-Dev] Strange memo behavior from cPickle

2006-08-01 Thread Bruce Christensen
We seem to have stumbled upon some strange behavior in cPickle's memo use when pickling instances. Here's the repro: [mymodule.py] class C: def __getstate__(self): return ('s1', 's2', 's3') [interactive interpreter] Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win

Re: [Python-Dev] Strange memo behavior from cPickle

2006-08-01 Thread Tim Peters
[Bruce Christensen] > We seem to have stumbled upon some strange behavior in cPickle's memo > use when pickling instances. > > Here's the repro: > > [mymodule.py] > class C: > def __getstate__(self): return ('s1', 's2', 's3') > > [interactive interpreter] > Python 2.4.3 (#69, Mar 29 2006, 17:35

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-01 Thread Greg Ewing
M.-A. Lemburg wrote: > You often have a need for controlled rounding when doing > financial calculations You should NOT be using binary floats for money in the first place. > or in situations where you want to > compare two floats with a given accuracy, Pseudo-rounding to decimal places is n

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-01 Thread Simon Burton
On Sat, 29 Jul 2006 15:44:33 +1200 Greg Ewing <[EMAIL PROTECTED]> wrote: > Michael Urman wrote: > > The fact that > > round returns a float rather than an int, while intentional, does not > > feature prominently in one's mine when the first version yielded the > > expected results. > > As an asid

[Python-Dev] internal weakref API should be Py_ssize_t?

2006-08-01 Thread Neal Norwitz
I'm wondering if the following change should be made to Include/weakrefobject.h: -PyAPI_FUNC(long) _PyWeakref_GetWeakrefCount(PyWeakReference *head); +PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head); And the 2 other files which use this (weakref obj and module). Should t

Re: [Python-Dev] internal weakref API should be Py_ssize_t?

2006-08-01 Thread Tim Peters
[Neal Norwitz] > I'm wondering if the following change should be made to > Include/weakrefobject.h: Yes. > -PyAPI_FUNC(long) _PyWeakref_GetWeakrefCount(PyWeakReference *head); > +PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head); > > And the 2 other files which use this (w

Re: [Python-Dev] internal weakref API should be Py_ssize_t?

2006-08-01 Thread Fred L. Drake, Jr.
Neal Norwitz wrote: > I'm wondering if the following change should be made to > Include/weakrefobject.h: On Wednesday 02 August 2006 00:53, Tim Peters wrote: > Yes. ... > +1 on biting the bullet for 2.5. Agreed. This should definately go with the rest of the Py_ssize_t changes. -Fred --

[Python-Dev] Weekly Python Patch/Bug Summary

2006-08-01 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 396 open ( -5) / 3354 closed (+12) / 3750 total ( +7) Bugs: 864 open (-32) / 6087 closed (+52) / 6951 total (+20) RFE : 226 open ( +2) / 234 closed ( +1) / 460 total ( +3) New / Reopened Patches __ Move fire