473,671 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is len() restricted to (positive) 32-bit values?

I have a class that wraps a large file and tries to make it look like a
string w.r.t. slicing. Here, "large file" means on the order of
hundreds of GB. All the slicing/indexing stuff through __getitem__()
works fine, but len() is quite broken. It seems to be converting the
value returned by __len__() to a 32-bit integer. If the conversion
yields a negative number, it raises an exception.

I'm running Python 2.4.1 on an Opteron running RedHat FC3. It's a
64-bit processor, and Python ints appear to be 64-bit as well, so even
if len() only works with ints, it should still be able to handle 64-bit
values.

Here's a simple example that shows what I'm talking about:
import sys
sys.version '2.4.1 (#1, Jun 22 2005, 16:00:46) \n[GCC 3.4.2 20041017 (Red Hat
3.4.2-6.fc3)]' type(1<<50) <type 'int'> type(1<<70) <type 'long'> class LenTest: .... def __len__(self):
.... return 49000000000
.... x = LenTest()
x.__len__() 49000000000 len(x)

1755359744

Is this a bug, a design decision, or do I have something misconfigured
in my Python build?

-Josh

Dec 30 '05 #1
0 971

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
2555
by: Sean R. Lynch | last post by:
I've been playing around with Zope's RestrictedPython, and I think I'm on the way to making the modifications necessary to create a capabilities-based restricted execution system. The idea is to strip out any part of RestrictedPython that's not necessary for doing capabilities and do all security using just capabilities. The basic idea behind capabilities is that you don't give any piece of code you don't trust a reference to something...
13
4011
by: Rolf Magnus | last post by:
Hi, I would like to embed a python interpreter within a program, but since that program would be able to automatically download scripts from the internet, I'd like to run those in a restricted environment, which basically means that I want to allow only a specific set of modules to be used by the scripts, so that it wouldn't be possible for them to remove files from the hard drive, kill processes or do other nasty stuff. Is there any...
1
11323
by: Edward | last post by:
Access 97 SR 2 Front End SQL Server 7.00.1063 Back End When I attempt to relink the tables in my Access app. I am suddenly getting this weird error message = "ODBC--Call Failed", followed by "Restricted Data Type Attribute Violation(#0)". This problem did not manifest last time I tried a few weeks ago, and so far as I know there have been no software changes such as Service Packs etc.
0
1099
by: Jussi | last post by:
Hi! I have a COM server object in which I have set certain interfaces restricted/hidden. For example With VB client these attributes works as excpected. However if I use this same COM component from C# client hidden/restricted attributes seems to have no effect. Is there any way to restrict C# client's access to certain
1
7754
by: Kiran_Juikar | last post by:
In my application, I want to copy some file from network location to local machine folder. It works fine for administrator but If I run it with restricted user (not having permissions to local machine folder) it gives me Access denied error. How can I programmatically give permission to the foder for restrcited user.
3
1413
by: Josué Maldonado | last post by:
Hello list, This is an inventory system where some users are restricted to view only certain suppliers, those restrictions are in a table called pedusers (username,supplierallowed), there are other kind of "superuser" who are not restricted, actually I created another table for them (userexcept). To select restricted rows I use this code: select * from prvdor where prvtiprov = 2 and
21
1707
by: iapain | last post by:
I'm developing a webIDE for python and I've 2 questions regarding it. 1. How can i disable some of the modules without deleting. e.g I wish to disable "os" module. 2. How can i force user code to access only his particular folder, I dont want to create uses in unix, e.g fp = open(PATH, 'w') # If this PATH is defined then use can access files else he cant .. is there is any way?
14
1287
by: Tor Erik Soenvisen | last post by:
Hi, (len() is 1) == (len() == 1) =True Is this the case for all numbers? I've tried running the following: for i in range(10000): for j in range(10000): if i != j:
63
5654
by: deepak | last post by:
Hi, Can someone give the standard function which can create positive integer value in C? Thanks, Deepak
15
2904
by: Michael B Allen | last post by:
I like to use limit pointers as sentinels when working on buffers of data. Meaning I use ptr < lim where ptr and lim are both pointers rather than n 0 to determine if it is safe to proceed writing to that location. The rationale is that it is simpler and thus safer because you're not constantly recomputing integer n. However, I've run into a case where this fails and I'd like to know what the experts would do. If I want to precompute...
0
8476
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8598
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7437
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2812
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1809
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.