Issue1761858

classification
Title: patch for [ 1560858 ] range(long,long) doesn't work
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, ukeshav
Priority: normal Keywords: patch

Created on 2007-07-27.08:56:16 by ukeshav, last changed 2007-07-30.04:14:35 by cgroves.

Files
File name Uploaded Description Edit Remove
__builtin__.patch ukeshav, 2007-07-27.08:56:16 patch file
Messages
msg2761 (view) Author: keshav upadhyaya (ukeshav) Date: 2007-07-27.08:56:16
i have done  some  changes in  __builtin__.java to make range() fucntion   acccept long numbers  but still we can support long value upto 2^63 - 1 because it is the upper limit of long.MAX_VALUE.

so now  up to 2^63-1 range() function is working fine.

Please fine the patch attached 

msg2762 (view) Author: Charlie Groves (cgroves) Date: 2007-07-30.04:14:35
Committed in r3366.  

I'm guessing you switched from an array of PyObject in your patch to a Vector to accumulate the objects for the range because an array in java can only be up to Integer.MAX_VALUE in length.  Switching to a Vector doesn't actually get around that problem; a Vector uses an array for its internal storage, so it'll hit it too.  Since we use arrays internally in PyList as well, I just added a check to prevent a user from creating a range with more than Integer.MAX_VALUE items in it.  If someone actually has enough ram to do something like that, we can worry about it then.

Just as a general Java usage tip, there's no reason to use Vector instead of List in code that can use Java 1.2.  Vector is synchronized by default, but you can get that behavior on a List with Collections.synchronizedList.  Vector is used in Jython currently, but that's only because that code was written long, long ago.
History
Date User Action Args
2007-07-27 08:56:16ukeshavcreate