[issue2482] Decimal(unicode)

2008-03-25 Thread Mark Dickinson

Mark Dickinson <[EMAIL PROTECTED]> added the comment:

The original bug here is fixed, so I'm closing this issue.  I've opened
a separate issue (issue 2486) for discussing changing the Decimal 
coefficient from str to bytes.

--
resolution:  -> fixed
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2482] Decimal(unicode)

2008-03-25 Thread Mark Dickinson

Mark Dickinson <[EMAIL PROTECTED]> added the comment:

str -> unicode regression fixed in r61904, r61906.

(I backported the fix to 2.5;  it's not absolutely clear that it's worth 
it, but this *is* a bug, and it seems worth not letting the various 
decimal.py versions diverge too much.)

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2482] Decimal(unicode)

2008-03-25 Thread Mark Dickinson

Mark Dickinson <[EMAIL PROTECTED]> added the comment:

I'm not sure that converting to bytes for Python 3.0 is going to
be a simple change.  For one thing, most of the arithmetic functions
have to do the reverse conversion (int -> str/bytes) at some point.

At the moment, an int -> bytes conversion has to go through unicode (I 
think);  something like  bytes(str(n), 'ascii'), so it's not 100% clear
that replacing str with bytes is going to produce a speed gain.

For now, I'll get the fix for the 2.5/2.6 problem in (it only
involves changing 3 lines in decimal.py, along with adding a few
extra tests).

Changing str -> bytes in 3.0 needs more careful thought, and some 
benchmarking.

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2482] Decimal(unicode)

2008-03-25 Thread Facundo Batista

Facundo Batista <[EMAIL PROTECTED]> added the comment:

Decimal needs to grow something like the following near the top of the
module:

try:
  _bytes = bytes
except NameError: # 2.5 or earlier
  _bytes = str

and then use _bytes instead of str as appropriate throughout the rest of
the module.

This will solve the actual problem, and scales well with 2.6 and 3k.

--
nosy: +facundobatista

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2482] Decimal(unicode)

2008-03-25 Thread Mark Dickinson

Changes by Mark Dickinson <[EMAIL PROTECTED]>:


--
assignee:  -> marketdickinson
nosy: +marketdickinson
versions: +Python 2.6

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2482] Decimal(unicode)

2008-03-25 Thread Oleg Broytmann

New submission from Oleg Broytmann <[EMAIL PROTECTED]>:

Decimal(u'123').to_eng_string() returns unicode in Python 2.5.2. That's
probably due to the optimization in decimal module, after which decimal
stores coefficient (mantissa) as a str, and doesn't coerce input to str.

See the thread at
http://mail.python.org/pipermail/python-dev/2008-March/078189.html

--
components: Library (Lib)
messages: 64488
nosy: phd
severity: normal
status: open
title: Decimal(unicode)
type: behavior
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>

__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com