Author mark.dickinson
Recipients eric.smith, ezio.melotti, mark.dickinson, rhettinger
Date 2009-07-30.10:10:33
SpamBayes Score 2.33251e-08
Marked as misclassified No
Message-id <1248948636.41.0.35710764805.issue6595@psf.upfronthosting.co.za>
In-reply-to
Content
Thanks for the feedback;  I've added 2.6, 2.7, 3.1 to the
versions and will backport.

[Eric]
> Since you're calling int() on the result, can't this code:
> self._int = str(int((intpart+fracpart).lstrip('0') or '0'))
> just be:
> self._int = str(int(intpart+fracpart))
> ?

Yes!  Thank you.  I'm not sure what (if anything) I was thinking here.

The str(int(...)) hack is quite an ugly way to normalize a string;  it 
also has the drawback of taking time quadratic in the length of the 
input.  In its defence: (a) I can't think of anything better; (b) this 
change seems to have no noticeable effect on the time to run the test-
suite, and (c) since all the arithmetic operations use string <-> int 
conversions anyway the quadratic time behaviour doesn't really make 
things any worse than they already are.

> And here, you already know diag is not None, so do you need the "or 
'0'"
> part?
> self._int = str(int(diag or '0')).lstrip('0')

I think *something* like this is needed, since diag can legitimately be 
the empty string.  It might be clearer as a proper if block, though:  
'if diag: ...  else: ...'.
History
Date User Action Args
2009-07-30 10:10:36mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, eric.smith, ezio.melotti
2009-07-30 10:10:36mark.dickinsonsetmessageid: <1248948636.41.0.35710764805.issue6595@psf.upfronthosting.co.za>
2009-07-30 10:10:34mark.dickinsonlinkissue6595 messages
2009-07-30 10:10:33mark.dickinsoncreate