Re: [Python-Dev] Decimal amp; amp; lt; -amp; amp; gt; float comparisons in py3k.

2010-03-20 Thread Glenn Linderman
On 3/19/2010 9:20 PM, Nick Coghlan wrote: Glenn Linderman wrote: The same person that would expect both 0 == 0 0.0 == 0.0 to be False... i.e. anyone that hasn't coded in Perl for too many years. Completely different - that is comparing numbers to strings. One can

Re: [Python-Dev] Decimal - float comparisons in py3k.

2010-03-20 Thread Mark Dickinson
On Fri, Mar 19, 2010 at 1:17 PM, Case Vanhorsen cas...@gmail.com wrote: On Fri, Mar 19, 2010 at 3:07 AM, Mark Dickinson dicki...@gmail.com wrote: On Fri, Mar 19, 2010 at 9:37 AM, Mark Dickinson dicki...@gmail.com wrote: Making hashes of int, float, Decimal *and* Fraction all compatible with

Re: [Python-Dev] Decimal - float comparisons in py3k.

2010-03-20 Thread Mark Dickinson
On Sat, Mar 20, 2010 at 12:10 AM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Nick Coghlan wrote: Mark Dickinson wrote: It seems to me that given the existing conflation of numeric equivalence and containment testing, going the whole hog and fixing the set membership problem for all of

[Python-Dev] Fraction arithmetic (Was: Decimal ... float comparisons in py3k)

2010-03-20 Thread Paul Moore
On 20 March 2010 04:20, Nick Coghlan ncogh...@gmail.com wrote: In the case of floats and Decimals, there's no ambiguity here that creates any temptation to guess - to determine a true/false result for a comparison, floats can be converted explicitly to Decimals without any loss of accuracy.

Re: [Python-Dev] Fraction arithmetic (Was: Decimal ... float comparisons in py3k)

2010-03-20 Thread Mark Dickinson
On Sat, Mar 20, 2010 at 11:41 AM, Paul Moore p.f.mo...@gmail.com wrote: On 20 March 2010 04:20, Nick Coghlan ncogh...@gmail.com wrote: In the case of floats and Decimals, there's no ambiguity here that creates any temptation to guess - to determine a true/false result for a comparison, floats

Re: [Python-Dev] Attribute lookup ambiguity

2010-03-20 Thread Pascal Chambon
Michael Foord a écrit : On 19/03/2010 18:58, Pascal Chambon wrote: Hello I've already crossed a bunch of articles detailing python's attribute lookup semantic (__dict__, descriptors, order of base class traversing...), but I have never seen, so far, an explanation of WHICH method did waht,

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Antoine Pitrou
Mark Dickinson dickinsm at gmail.com writes: On Fri, Mar 19, 2010 at 9:50 PM, Guido van Rossum guido at python.org wrote: There is one choice which I'm not sure about. Should a mixed float/Decimal operation return a float or a Decimal? I'll just say that it's much easier to return a

Re: [Python-Dev] Decimal - float comparisons in py3k.

2010-03-20 Thread Case Vanhorsen
On Sat, Mar 20, 2010 at 4:06 AM, Mark Dickinson dicki...@gmail.com wrote: On Fri, Mar 19, 2010 at 1:17 PM, Case Vanhorsen cas...@gmail.com wrote: On Fri, Mar 19, 2010 at 3:07 AM, Mark Dickinson dicki...@gmail.com wrote: On Fri, Mar 19, 2010 at 9:37 AM, Mark Dickinson dicki...@gmail.com wrote:

Re: [Python-Dev] Tracker reviews workflow and flags

2010-03-20 Thread R. David Murray
On Fri, 19 Mar 2010 23:20:52 -0400, Alexander Belopolsky alexander.belopol...@gmail.com wrote: I will not go into details here beyond referring to http://bugs.python.org/issue8154, but if you follow the link, you'll see that there was not a consensus on how the issue should be addressed and

Re: [Python-Dev] Decimal - float comparisons in py3k.

2010-03-20 Thread Terry Reedy
On 3/20/2010 7:06 AM, Mark Dickinson wrote: Will this change the result of hashing a long? I know that both gmpy and SAGE use their own hash implementations for performance reasons. I understand that CPython's hash function is an implementation detail, but there are external modules that rely

Re: [Python-Dev] Bug? syslog.openlog using ident quot; pythonquot; by default.

2010-03-20 Thread Antoine Pitrou
Sean Reifschneider jafo at tummy.com writes: I would propose changing the Python syslog() call to do the C equivalent of: if openlog_hasnt_been_called_before_now: if sys.argv[0]: syslog.openlog(os.path.basename(sys.argv[0])) In other words, if there's a script name and

[Python-Dev] Tracker opened/closed issue list: missing?

2010-03-20 Thread Terry Reedy
I did not receive the usual Friday tracker post on issues opened and closed during the past week. Did anyone else? I am reading via gmane. Terry Jan Reedy ___ Python-Dev mailing list Python-Dev@python.org

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Adam Olsen
On Sat, Mar 20, 2010 at 09:11, Antoine Pitrou solip...@pitrou.net wrote: Mark Dickinson dickinsm at gmail.com writes: On Fri, Mar 19, 2010 at 9:50 PM, Guido van Rossum guido at python.org wrote: There is one choice which I'm not sure about. Should a mixed float/Decimal operation return a

Re: [Python-Dev] Decimal - float comparisons in py3k.

2010-03-20 Thread Mark Dickinson
On Sat, Mar 20, 2010 at 3:17 PM, Case Vanhorsen cas...@gmail.com wrote: On Sat, Mar 20, 2010 at 4:06 AM, Mark Dickinson dicki...@gmail.com wrote: What external modules are there that rely on existing hash behaviour? I'm only aware of  gmpy and SAGE. And exactly what behaviour do they rely

Re: [Python-Dev] Tracker opened/closed issue list: missing?

2010-03-20 Thread Brian Curtin
On Sat, Mar 20, 2010 at 11:02, Terry Reedy tjre...@udel.edu wrote: I did not receive the usual Friday tracker post on issues opened and closed during the past week. Did anyone else? I am reading via gmane. Terry Jan Reedy I actually haven't seen that mail in a few weeks (subscribed to the

Re: [Python-Dev] Decimal - float comparisons in py3k.

2010-03-20 Thread Case Vanhorsen
On Sat, Mar 20, 2010 at 10:05 AM, Mark Dickinson dicki...@gmail.com wrote: On Sat, Mar 20, 2010 at 3:17 PM, Case Vanhorsen cas...@gmail.com wrote: On Sat, Mar 20, 2010 at 4:06 AM, Mark Dickinson dicki...@gmail.com wrote: What external modules are there that rely on existing hash behaviour?

Re: [Python-Dev] Tracker opened/closed issue list: missing?

2010-03-20 Thread R. David Murray
On Sat, 20 Mar 2010 11:11:17 -0600, Brian Curtin brian.cur...@gmail.com wrote: On Sat, Mar 20, 2010 at 11:02, Terry Reedy tjre...@udel.edu wrote: I did not receive the usual Friday tracker post on issues opened and closed during the past week. Did anyone else? I am reading via gmane.

Re: [Python-Dev] Fraction arithmetic (Was: Decimal ... float comparisons in py3k)

2010-03-20 Thread Guido van Rossum
On Sat, Mar 20, 2010 at 4:58 AM, Mark Dickinson dicki...@gmail.com wrote: On Sat, Mar 20, 2010 at 11:41 AM, Paul Moore p.f.mo...@gmail.com wrote: On 20 March 2010 04:20, Nick Coghlan ncogh...@gmail.com wrote: In the case of floats and Decimals, there's no ambiguity here that creates any

Re: [Python-Dev] Tracker opened/closed issue list: missing?

2010-03-20 Thread Martin v. Löwis
Darn. I bet I broke it when I added the 'languishing' status. I even thought about that at the time but didn't follow up on it. I'll see if I can figure out where the script lives. My guess is that the Debian upgrade killed it. Regards, Martin

Re: [Python-Dev] Decimal - float comparisons in py3k.

2010-03-20 Thread Guido van Rossum
On Sat, Mar 20, 2010 at 4:16 AM, Mark Dickinson dicki...@gmail.com wrote: True.  The reason I was concentrating on the hashes is that it's not immediately obvious that it's even *possible* to find a decent hash function that's efficient to compute and gives equal results for numerically equal

Re: [Python-Dev] Decimal - float comparisons in py3k.

2010-03-20 Thread Mark Dickinson
On Sat, Mar 20, 2010 at 7:56 PM, Guido van Rossum gu...@python.org wrote: I propose to reduce all hashes to the hash of a normalized fraction, which we can define as a combination of the hashes for the numerator and the denominator. Then all we have to do is figure fairly efficient ways to

Re: [Python-Dev] Silencing DeprecationWarning by default in Python 2.7 is silencing division warnings

2010-03-20 Thread Brett Cannon
On Sat, Mar 6, 2010 at 12:43, Brett Cannon br...@python.org wrote: I see two possible fixes for this. One is to not silence DeprecationWarning if Py_DivisionWarningFlag is set to = 1. The other is to introduce a new subclass of DeprecationWarning called IntegerDivisionWarning and have that

Re: [Python-Dev] Decimal amp; amp; lt; -amp; amp; gt; float comparisons in py3k.

2010-03-20 Thread Greg Ewing
Glenn Linderman wrote: One can argue that either way, that it is completely different, or completely the same. An important difference is that there is no intermediate type that can be compared with both ints and strings. Another relevant difference is that numbers are just one of many

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Greg Ewing
Adam Olsen wrote: For a little context, we have this numeric tower: int - Fraction - float - complex Decimal is more precise, and pays a performance cost for it. It also seems odd to stick it between float and complex (nobody's planning a ComplexDecimal, right?) That suggests it should go

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Jeffrey Yasskin
On Sat, Mar 20, 2010 at 4:20 PM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Adam Olsen wrote: For a little context, we have this numeric tower: int - Fraction - float - complex Decimal is more precise, and pays a performance cost for it.  It also seems odd to stick it between float and

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Mark Dickinson
On Sat, Mar 20, 2010 at 11:20 PM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: * Decimal and float really belong side-by-side in the tower, rather than one above the other. Neither of them is inherently any more precise or exact than the other. Except that float is fixed-width (typically 53

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Guido van Rossum
On Sat, Mar 20, 2010 at 4:46 PM, Mark Dickinson dicki...@gmail.com wrote: On Sat, Mar 20, 2010 at 11:20 PM, Greg Ewing greg.ew...@canterbury.ac.nz wrote: * Decimal and float really belong side-by-side in the tower, rather than one above the other. Neither of them is inherently any more

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Adam Olsen
On Sat, Mar 20, 2010 at 17:20, Greg Ewing greg.ew...@canterbury.ac.nz wrote: There are two ways in which that linear tower is overly simplistic: * It conflates the notions of exactness and width. They're really orthogonal concepts, and to reflect this you would need two parallel towers, with

Re: [Python-Dev] Decimal amp; amp; lt; -amp; amp; gt; float comparisons in py3k.

2010-03-20 Thread Nick Coghlan
Greg Ewing wrote: Antoine Pitrou wrote: We forbid comparisons when there is a real danger or ambiguity, such as unicode vs. bytes. There is no such danger or ambiguity when comparing a decimal with a float. So do you think that float(0.1) and Decimal(0.1) should be equal or not, and

Re: [Python-Dev] Decimal amp; amp; lt; -amp; amp; gt; float comparisons in py3k.

2010-03-20 Thread Nick Coghlan
Glenn Linderman wrote: Thanks, though for the nice chart from an internals guy, you confirmed all that I thought I knew about how this presently works, from PEP and manual reading, a bit of experimentation, and the discussions here. I'll confess to a bit of interpreter prompt experimentation

Re: [Python-Dev] Attribute lookup ambiguity

2010-03-20 Thread Michael Foord
On 20/03/2010 12:00, Pascal Chambon wrote: Michael Foord a écrit : On 19/03/2010 18:58, Pascal Chambon wrote: Hello I've already crossed a bunch of articles detailing python's attribute lookup semantic (__dict__, descriptors, order of base class traversing...), but I have never seen, so

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Nick Coghlan
Guido van Rossum wrote: I think we should seriously reconsider allowing mixed arithmetic involving Decimal, not just mixed comparisons. I'm glad I'm not the only one that started wondering that. I wasn't quite game enough to actually suggest it though :) There is one choice which I'm not

Re: [Python-Dev] Attribute lookup ambiguity

2010-03-20 Thread Nick Coghlan
Michael Foord wrote: Well, the documentation you pointed to specifies that __getattr__ will be called if __getattribute__ raises an AttributeError, it just doesn't specify that it is done by object.__getattribute__ (which it isn't). And as for why not: because __getattribute__ implementations

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Raymond Hettinger
On Mar 20, 2010, at 6:54 PM, Nick Coghlan wrote: I suggest a 'linearised' numeric tower that looks like: int - Decimal - Fraction - float - complex Is that a typo? Shouldn't Decimal and float go between Fraction and complex? The abstract numeric tower is: Number Complex Real

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Raymond Hettinger
On Mar 20, 2010, at 4:27 PM, Jeffrey Yasskin wrote: When designing it, I tried to include a notion of exact/inexact types, but we couldn't find anything practical to do with them, so we took them out. The were also other reasons that they were taken out. The notion of inexactness is a

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Greg Ewing
Mark Dickinson wrote: Except that float is fixed-width (typically 53 bits of precision), while Decimal allows a user-specified, arbitrarily large, precision; Yes, but it still has *some* fixed limit at any given moment, so the result of an operation on Decimals always has the potential to

Re: [Python-Dev] Decimal amp; amp; lt; -amp; amp; gt; float comparisons in py3k.

2010-03-20 Thread Greg Ewing
Nick Coghlan wrote: Note that Antoine's point was that float(0.1) and Decimal.from_float(0.1) should compare equal. That would mean that Decimal(0.1) != float(0.1), which might be surprising to someone who didn't realise they were mixing floats and decimals. -- Greg

Re: [Python-Dev] Attribute lookup ambiguity

2010-03-20 Thread Greg Ewing
Michael Foord wrote: Well, the documentation you pointed to specifies that __getattr__ will be called if __getattribute__ raises an AttributeError, it just doesn't specify that it is done by object.__getattribute__ (which it isn't). If __getattribute__ raises an exception, it won't get a

Re: [Python-Dev] Mixing float and Decimal -- thread reboot

2010-03-20 Thread Greg Ewing
Nick Coghlan wrote: int - Decimal - Fraction - float - complex I don't think it's a good idea to put Decimal below Fraction, because Decimal has to be considered an implicitly inexact type like float, and we don't want to coerce from an inexact type to an exact one. -- Greg

Re: [Python-Dev] Decimal amp; amp; lt; -amp; amp; gt; float comparisons in py3k.

2010-03-20 Thread Adam Olsen
On Sat, Mar 20, 2010 at 22:48, Greg Ewing greg.ew...@canterbury.ac.nz wrote: Nick Coghlan wrote: Note that Antoine's point was that float(0.1) and Decimal.from_float(0.1) should compare equal. That would mean that Decimal(0.1) != float(0.1), which might be surprising to someone who didn't