[Python-Dev] [patch] fpconst for python3 (original) (raw)
Benjamin Peterson benjamin at python.org
Wed Oct 20 03:07:44 CEST 2010
- Previous message: [Python-Dev] [patch] fpconst for python3
- Next message: [Python-Dev] [patch] fpconst for python3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
fpconst developers?
2010/10/19 Neal Becker <ndbecker2 at gmail.com>:
Where should I send this patch?
diff -u fpconst-0.7.2/fpconst.py fpconst-0.7.2.new/fpconst.py --- fpconst-0.7.2/fpconst.py 2005-02-24 12:42:03.000000000 -0500 +++ fpconst-0.7.2.new/fpconst.py 2010-10-19 20:55:07.407765664 -0400 @@ -40,18 +40,18 @@ ident = "$Id: fpconst.py,v 1.16 2005/02/24 17:42:03 warnes Exp $" import struct, operator +from functools import reduce # check endianess -bigendian = struct.pack('i',1)[0] != '\x01' - +bigendian = struct.pack('i',1)[0] != 1 # and define appropriate constants if(bigendian): - NaN = struct.unpack('d', '\x7F\xF8\x00\x00\x00\x00\x00\x00')[0] - PosInf = struct.unpack('d', '\x7F\xF0\x00\x00\x00\x00\x00\x00')[0] + NaN = struct.unpack('d', b'\x7F\xF8\x00\x00\x00\x00\x00\x00')[0] + PosInf = struct.unpack('d', b'\x7F\xF0\x00\x00\x00\x00\x00\x00')[0] NegInf = -PosInf else: - NaN = struct.unpack('d', '\x00\x00\x00\x00\x00\x00\xf8\xff')[0] - PosInf = struct.unpack('d', '\x00\x00\x00\x00\x00\x00\xf0\x7f')[0] + NaN = struct.unpack('d', b'\x00\x00\x00\x00\x00\x00\xf8\xff')[0] + PosInf = struct.unpack('d', b'\x00\x00\x00\x00\x00\x00\xf0\x7f')[0] NegInf = -PosInf def doubleasbytes(dval):
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/benjamin%40python.org
-- Regards, Benjamin
- Previous message: [Python-Dev] [patch] fpconst for python3
- Next message: [Python-Dev] [patch] fpconst for python3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]