Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Limitation
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Limitation

by ptremblett on Sun Oct 04, 2020 12:40 am

I am implementing an IBM 1130 simulator on a Grand Central because it is the only board that has enough RAM. It is about 3500 LOC so far. I am running into what appears to be a limitation. I get the message: 'XXXXX' object has no attribute '_yyyy'. I know this is not so because the code runs using Python 3 on my Mac. I have found a workaround. Each time I get this message, I make the instance variable being reported as a missing attribute a class variable and the code gets farther until I get the message for another instance variable. In my case, I don't mind doing this because almost all the classes I am using are singletons.

My question is if the apparent limitation I am seeing a known limitation (i.e., is there a limit to the total number of instance variable?)

ptremblett
 
Posts: 10
Joined: Fri Jun 12, 2020 12:03 am

Re: Limitation

by siddacious on Mon Oct 05, 2020 1:10 pm

It's hard to say what exactly the issue is without seeing the code.

Can you re-produce the error with a smaller codebase? Is that the literal error? If so it sounds like the error you get when trying to import a private attribute into another module. If so, this is known behavior (by me at least ;0 ) however if it is different than the behavior in Python 3, that's work looking into.

Regarding your direct question, no I don't believe there is a limit on the number of instance variables, other than the limits from memory which would show as failing to allocate memory.

Please see if you can reproduce this error with a smaller code base and let us know what you find. In either case, we will need to see the actual code that is creating the errors to be able to help.

Sounds like a cool project!

siddacious
 
Posts: 338
Joined: Fri Apr 21, 2017 3:09 pm

Re: Limitation

by ptremblett on Mon Oct 05, 2020 2:57 pm

I do not think it is a case of importing a private attribute into another class. In my case, I have an instance inst_a of class A that I am using in inst_b of class B.

inst_a has two instance variables, x and y and in inst_b I do:

Code: Select all | TOGGLE FULL SIZE
print(inst_a.x)
print(inst_a.y

I see x and y printed.

Then, in class A, I add:

Code: Select all | TOGGLE FULL SIZE
self.inst_z = ‘this is z’

Now, in B, I add

Code: Select all | TOGGLE FULL SIZE
print(inst_a.z)

, I get the missing attribute message.

Then, if I make x a class variable, I see x, y, and z printed.

That scenario leads me to. Believe it is not a visibility or scope problem.

I realize it is difficult to try to get a handle on what is going on without access to the code. Right now, I am heads down getting the simulator to the point where it is successfully completing the IPL sequence that loads the operating system. When I reach that point, I will go back and modify the code to duplicate the failure and make the broken code available. Ultimately, the project will be available in GitHub and I think it will serve as a good example of what can be done with CircuitPython

ptremblett
 
Posts: 10
Joined: Fri Jun 12, 2020 12:03 am

Re: Limitation

by ptremblett on Mon Oct 05, 2020 3:09 pm

I should add that after I make inst_z a class variable and all three print statements work, now if I add an instance variable inst_xxx and try to print it, I will get the missing attribute message. Additionally, having doen that, if I now make inst_zzz a class variable and make inst_z an instance variable again, inst_zzz will prnt and inst_z will be reported as missing

ptremblett
 
Posts: 10
Joined: Fri Jun 12, 2020 12:03 am

Re: Limitation

by ericwertz on Tue Oct 06, 2020 6:49 pm

The only limitation that I've run into along these lines is when I discovered that I couldn't hang an attribute off of an object, if that object was a function. I tried to do this as a poor-man's way of implementing a local, static variable in a function, similar to what one can do in C. I had no trouble doing this in Python 3, but it didn't work in Micro/CircuitPython.

I later found that this was documented not to work in Micro/CircuitPython, and is one of a number of things that were not implemented there that are in related implementations of CPython3.

You might want to check the documented cut-outs from MicroPython to see if the feature you're trying to use has been explicitly excised.

gl,
-e

ericwertz
 
Posts: 75
Joined: Sun Jun 01, 2008 4:18 am

Re: Limitation

by ptremblett on Wed Oct 07, 2020 12:10 am

Thanks for the tip. I had not thought of taking a look at MicroPython as a way to check what might be going on with CircuitPython.

The good news is I now have the simulator successfully loading the operating system and have overcome the RAM limitation on the Grand Central that was preventing me from simulating an 1130 with maximum memory of 32K (in real life, most machines were 8K). I did it by implementing paged memory on the Grand Central

ptremblett
 
Posts: 10
Joined: Fri Jun 12, 2020 12:03 am

Re: Limitation

by kevinjwalters on Wed Oct 07, 2020 6:41 pm

For the object has no attribute error were there any errors before those, perhaps around import statements?

kevinjwalters
 
Posts: 764
Joined: Sun Oct 01, 2017 3:15 pm

Re: Limitation

by ptremblett on Wed Oct 07, 2020 10:00 pm

No, there were no errors around import statements. I have seen such errors but it did not take me long to figure them out and realize what I was doing to cause they. It was almost always circular imports.

ptremblett
 
Posts: 10
Joined: Fri Jun 12, 2020 12:03 am

Please be positive and constructive with your questions and comments.