Tutor profile: Gavin C.
Subject: Python Programming
How would one create an idempotent object in the Python programming language. What are "magic methods"?
To create an idempotent object in python overwrite the current self.__dict__ attribute of each initialized object with a global dictionary containing the objects attributes. The global object will be the same memory location for each new object instance and the self.__dict__ field is the attribute data for that current instance. By setting the current, local data to the global shared data, each new instantiation will simply be set to the same underlying application data, making them effectively a singe object. Magic methods are implicit functions implemented for each python class. Much like the __dict__ attribute of a class, they are inherited functions which implement all system functions by python such as addition, subtraction, dictionary retrievals, and length calculations.
Subject: C Programming
How would you create an idempotent object in C and in what cases might such a thing be useful?
An idempotent object means there is only one such instance of that object in the program or system. One way to create such an object is specifying a physical memory location in the object initialization and maintaining a flag if that object has been created. That memory location will be constant through all programs irregardless of the context call, and will contain the exact same data. The flag will help us ensure that we do not reinitialize the object a second time and write over data. Such an object is useful in creating semaphores or mutexes where it is important to maintain constant access to a single object across multiple programs.
Subject: Assembly Language
Write a program in MIPS assembly to load the next value in an array of 32-bit integers starting at the memory address pointed to by register 3, into register 1. Assume you are woking on a byte addressable machine.
ADDI R3, 4, R4 #move memory address one integer over in memory LDR R1, R3 #load value at memory address into register 1
needs and Gavin will reply soon.