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

2006-08-02 Thread Christian Tanzer
Greg Ewing <[EMAIL PROTECTED]> wrote: > What's the feeling about this? If, e.g. int() > were changed in Py3k to round instead of truncate, > would it cause anyone substantial pain? Gratuitous breakage! I shudder at the thought of checking hundreds of int-calls to see if they'd still be correct

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

2006-08-02 Thread Greg Ewing
Raymond Hettinger wrote: > -1 on an extra built-in just to save the time for function call The time isn't the main issue. The main issue is that almost all the use cases for round() involve doing an int() on it afterwards. At least nobody has put forward an argument to the contrary yet. Sure you

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

2006-08-02 Thread James Y Knight
On Aug 2, 2006, at 11:26 PM, Raymond Hettinger wrote: > Also, -10 on changing the semantics of int() to round instead of > truncate. The truncating version is found is so many other languages > and book examples, that it would be a disaster for us to choose a > different meaning. I'd be happy to

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

2006-08-02 Thread Raymond Hettinger
>> Most typical uses of round() don't use the >> optional argument, true, but I still fail >> to see what returning an integer instead of >> a float would buy you. > > > It saves you a function call in the vast > majority of cases, where an int is what > you ultimately want. > -1 on an extra buil

Re: [Python-Dev] struct module and coercing floats to integers

2006-08-02 Thread Bob Ippolito
On Jul 28, 2006, at 1:35 PM, Bob Ippolito wrote: > It seems that the pre-2.5 struct module has some additional > undocumented behavior[1] that didn't percolate into the new version: > http://python.org/sf/1530559 > > Python 2.4 and previous will coerce floats to integers when necessary > as such

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

2006-08-02 Thread Greg Ewing
M.-A. Lemburg wrote: > Believe me: you have to if you want to do more > advanced calculus related to pricing and risk > analysis of derivatives. When you do things like that, you're treating money as though it were a continuous quantity. This is an approximation, so you can tolerate having small

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

2006-08-02 Thread Greg Ewing
Nick Coghlan wrote: > Another option would be to provide this as a method of float objects > (similar to decimal). That wouldn't be so good. Either kind of rounding ought to be a function that you can apply without knowing what kind of number you've got -- int, float, Decimal, or something else.

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

2006-08-02 Thread Greg Ewing
Michael Chermside wrote: > (Why you would WANT > more than around 53 bits of precision is a different question, but > Decimal handles it.) You can't have travelled far beyond Alpha Centauri recently. The major interstellar banking corporations need *quite* a lot of bits for dealing with the econom

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

2006-08-02 Thread Greg Ewing
Nick Maclaren wrote: > I am unaware of > any technical grounds to prefer one over the other (i.e. the reasons > for wanting each are equally balanced). If they're equally balanced in the sense of there being equal numbers of use cases for both, that would seem to be a reason to *have* both. What'

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

2006-08-02 Thread Simon Burton
On Wed, 2 Aug 2006 07:21:02 -0400 "Chermside, Michael" <[EMAIL PROTECTED]> wrote: > > You wrote: > > (ie. I am wondering if truncating the float representation > > of an int always gives back the original int). > > Yes it does, because all integers that can be expressed as floats > can be expres

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

2006-08-02 Thread Travis Oliphant
Nick Coghlan wrote: > > > One possibility would be to invert the sense of that flag and call it > "typeerror", which probably more accurately reflects what it's intended for - > it's a way of telling the function "if this object does not have the correct > type, tell me by setting this flag in

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

2006-08-02 Thread Guido van Rossum
All, please decide without me. On 8/1/06, Nick Coghlan <[EMAIL PROTECTED]> wrote: > 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 typ

Re: [Python-Dev] TRUNK FREEZE 2006-07-03, 00:00 UTC for 2.5b3

2006-08-02 Thread Neal Norwitz
This looks like it needs to be fixed as it's a regression. As Skip said, bug fixes are allowed. There will still be at least one release candidate. It's looking like c1 will be around Aug 18 and final around Sept 12. I'll update the PEP when I get a chance and confirm all the dates. n -- On 8

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

2006-08-02 Thread BJörn Lindqvist
On 8/2/06, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > Greg Ewing wrote: > > In all my programming so far I've found > > numerous uses for round-to-int, and exactly > > zero uses for round-binary-float-to-decimal- > > places. So from my point of view, the YAGNI > > applies to the *current* behavour

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

2006-08-02 Thread M.-A. Lemburg
Michael Chermside wrote: > Marc-Andre Lemburg writes: >> You often have a need for controlled rounding when doing >> financial calculations or [other reason snipped] > > Hmm. Not in the banks _I_ have worked at! We *never* use binary > floating point for money. The decimal class is fairly useful i

Re: [Python-Dev] TRUNK FREEZE 2006-07-03, 00:00 UTC for 2.5b3

2006-08-02 Thread skip
>> Please help the release team out by not making checkins on the trunk >> after that time until I send out an email that the release is done. Jean-Paul> Does this mean that there is no further opportunity to Jean-Paul> resolve regressions such as Jean-Paul>

Re: [Python-Dev] TRUNK FREEZE 2006-07-03, 00:00 UTC for 2.5b3

2006-08-02 Thread Jean-Paul Calderone
On Wed, 2 Aug 2006 22:29:44 +1000, Anthony Baxter <[EMAIL PROTECTED]> wrote: >The trunk is FROZEN from 00:00 UTC/GMT on 03 July 2006. That's in about 12 >hours from now. This is for the third (and final, hopefully!) beta of 2.5. > >Please help the release team out by not making checkins on the trun

[Python-Dev] TRUNK FREEZE 2006-07-03, 00:00 UTC for 2.5b3

2006-08-02 Thread Anthony Baxter
The trunk is FROZEN from 00:00 UTC/GMT on 03 July 2006. That's in about 12 hours from now. This is for the third (and final, hopefully!) beta of 2.5. Please help the release team out by not making checkins on the trunk after that time until I send out an email that the release is done. Thanks

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

2006-08-02 Thread M.-A. Lemburg
Greg Ewing wrote: > 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. Believe me: you have to if you want to do more advanced calculus related to pricing and risk

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

2006-08-02 Thread Nick Coghlan
Michael Chermside wrote: > Greg Ewing writes: >> [I propose for Py3k that] builtin round() >> to return an int, and have something somewhere >> else, such as math.fround(), for round-to-float. > > +1. > > The need to convert float to int is pervasive. The need to round (binary) > floats to intege

Re: [Python-Dev] FW: using globals

2006-08-02 Thread Ronald Oussoren
On Wednesday, August 02, 2006, at 01:02PM, Werkhoven J.P. van (Sjaak) <[EMAIL PROTECTED]> wrote: >> Hi, >> >> I have got a problem with importing global variables. For instance I have >> got two files: Your message is off-topic for python-dev, this list is for the development OF python, not

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

2006-08-02 Thread Michael Chermside
Nick Maclaren: > The "wobbling precision" effect may be overstated, > but is real, and gets worse the larger the base is. To the best of my > knowledge, that is almost the only way in which binary is more accurate > than decimal, in absolute terms, and it is a marginal difference. Okay, that make

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

2006-08-02 Thread Nick Maclaren
Michael Chermside <[EMAIL PROTECTED]> wrote: > > > Decimal doesn't even help people who care about accuracy. > > Not true! The float class is incapable of maintaining 700 digits of > precision, but Decimal handles it just fine. (Why you would WANT > more than around 53 bits of precision is a differ

[Python-Dev] FW: using globals

2006-08-02 Thread Werkhoven J.P. van (Sjaak)
> Hi, > > I have got a problem with importing global variables. For instance I have > got two files: > > # t1.py #t2.py > > counter = 1 > > def counter_adder(filenr):def > show_a

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

2006-08-02 Thread Michael Chermside
Greg Ewing writes: > [I propose for Py3k that] builtin round() > to return an int, and have something somewhere > else, such as math.fround(), for round-to-float. +1. The need to convert float to int is pervasive. The need to round (binary) floats to integer (or other decimal) floats is _much_ le

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

2006-08-02 Thread Nick Maclaren
Greg Ewing <[EMAIL PROTECTED]> wrote: > > You should NOT be using binary floats for money > in the first place. Or floating-point at all, actually. But binary floating-point is definitely unsuited for such a use. > Pseudo-rounding to decimal places is not > the right way to do that. The right wa

[Python-Dev] Releasemanager, please approve #1532975

2006-08-02 Thread Thomas Heller
Approval requested for patch: http://python.org/sf/1532975 Thanks, Thomas ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mai