diff --git a/max submission/reading_notes b/max submission/reading_notes new file mode 100644 index 0000000..1ecc1d0 --- /dev/null +++ b/max submission/reading_notes @@ -0,0 +1,155 @@ +Von Neumann's model: +Von Neumann's model, also known as the Von Neumann architecture or the Von Neumann machine, refers to the conceptual design of a computer architecture. It was proposed by the Hungarian American mathematician and computer scientist John von Neumann in the late 1940s. + +The Von Neumann architecture describes a computer system that consists of the following key components: + +Central Processing Unit (CPU): The CPU is responsible for executing instructions and performing arithmetic and logical operations. It consists of an arithmetic logic unit (ALU) and a control unit. + +Memory: The computer's memory is used to store both data and instructions. In the Von Neumann model, memory is organized as a linear sequence of addressable storage locations, where each location can hold a fixed amount of data. Instructions and data are stored together in the same memory. + +Input/Output (I/O): The I/O devices enable communication between the computer and the external world. This includes devices such as keyboards, mice, displays, printers, and storage devices. + +Bus: The bus is a communication pathway that allows data and instructions to be transferred between the CPU, memory, and I/O devices. It consists of address lines, data lines, and control lines. + +Instruction Set: The Von Neumann architecture employs a stored program concept, where instructions are represented in binary form and stored in memory. The CPU fetches instructions from memory, decodes them, and executes them sequentially. + +Sequential Execution: The Von Neumann architecture follows a sequential execution model, where instructions are executed one after another in a predetermined order, unless explicitly modified by branching or looping instructions. +Mutable: +In Python, the term "mutable" refers to an object's ability to be modified or changed after it has been created. In other words, if an object is mutable, its state can be altered by adding, removing, or modifying its elements or attributes. +# Mutable list +my_list = [1, 2, 3] +my_list.append(4) +print(my_list) # Output: [1, 2, 3, 4] +On the other hand, some objects in Python are immutable, which means their state cannot be changed after they are created. Examples of immutable objects include strings, numbers (integers, floats), and tuples. When you modify an immutable object, a new object is created instead. +# Immutable tuple +my_tuple = (1, 2, 3) +new_tuple = my_tuple + (4,) +print(my_tuple) # Output: (1, 2, 3) +print(new_tuple) # Output: (1, 2, 3, 4) + +garbage-collected: +In computer programming, garbage collection is a mechanism that automatically manages the memory used by a program. It frees up memory that is no longer needed, allowing it to be reused by other parts of the program. Garbage collection is especially useful in languages that provide automatic memory management, such as Python. + +circular references: +Circular references, also known as reference cycles, occur in programming languages when a group of objects reference each other in a way that creates a loop or cycle of references. This means that each object in the cycle refers to at least one other object in the cycle, forming a closed chain of references. +In languages like Python that employ automatic memory management, circular references can lead to memory leaks, where memory occupied by unused objects is not reclaimed. This can result in the program consuming more and more memory over time, potentially leading to performance issues or crashes. + +arithmetic operators: +Arithmetic operators are used in programming languages, including Python, to perform mathematical operations on numerical values. Python provides several arithmetic operators that allow you to perform addition, subtraction, multiplication, division, and more. + +A fruitful optimization: +One example of a fruitful optimization is loop unrolling. Loop unrolling is a technique used to optimize the execution speed of loops by reducing loop control overhead and increasing instruction-level parallelism. + +In a loop, the program executes a set of instructions repeatedly until a certain condition is met. Loop unrolling aims to reduce the number of iterations by increasing the number of instructions executed per iteration. This can lead to improved performance by reducing the overhead associated with loop control, such as loop variable updates and condition checks. + +C function: +A C function is a block of code in the C programming language that performs a specific task and can be called or invoked from other parts of a C program. Functions in C allow for modular programming, code reuse, and better organization of code. + +C3 method: +The C3 method, also known as the C3 linearization algorithm, is a method used in multiple inheritance to determine the order in which methods should be resolved or inherited from different parent classes. It is commonly used in programming languages that support multiple inheritance, such as Python. + +The C3 method was developed by the developers of the programming language Dylan and later adopted by other languages, including Python. + +The C3 method follows a specific algorithm to generate a linearization or method resolution order (MRO) for a class hierarchy. The linearization ensures that the order of method resolution is consistent and avoids conflicts and ambiguities that may arise due to multiple inheritance. + + ‘diamond’ inheritance structures: +Diamond inheritance, also known as the diamond problem or diamond inheritance ambiguity, is a specific situation that arises in some programming languages with multiple inheritance. It occurs when a class inherits from two or more classes, which in turn inherit from a common base class. The inheritance hierarchy forms a diamond shape, hence the name. + A + / \ + B C + \ / + D +In this diagram, classes B and C inherit from class A, and class D inherits from both B and C. As a result, D indirectly inherits from A through multiple paths. This creates an ambiguity when resolving method or attribute lookup. + +The diamond problem arises when a method or attribute is invoked on an instance of D, and there are conflicting implementations or definitions of the same method or attribute in classes B, C, or A. In such cases, it is unclear which implementation should be used. + +socket objects: +Socket objects are programming constructs used in network programming to establish communication channels between devices over a network. They provide an interface for sending and receiving data across different network protocols, such as TCP/IP or UDP. + +In most programming languages, including Python, socket objects are used to create and manipulate sockets. Sockets enable communication between a client and a server or between two peers by providing methods and properties to establish connections, send and receive data, and manage network-related operations. + + positional arguments: +Positional arguments refer to the arguments passed to a function or method based on their position or order. When invoking a function or method, positional arguments are provided in the order specified by the function's definition or documentation. + +In many programming languages, including Python, function parameters can be defined as positional parameters. When calling the function, you must provide values for these parameters in the same order they are defined. + +nested functions: +Nested functions, also known as inner functions, are functions defined inside another function. In many programming languages, including Python, functions can be defined within the scope of another function. + + line numbers: +In programming, line numbers are often associated with the lines of code within a file or program. They serve as a reference to locate specific lines for various purposes, such as debugging, error messages, or code navigation. + +Many integrated development environments (IDEs) and text editors display line numbers alongside the code to make it easier for developers to refer to specific lines. These line numbers typically appear on the left-hand side of the code editor or in the margin. + + #boolean context: + #In programming, a boolean context refers to a situation where a condition or expression is evaluated as either true or false. + #A boolean context typically occurs in control flow statements, such as if statements or while loops, where the condition determines whether + #a certain block of code should be executed or repeated. + + #Ellipsis: + #an ellipsis (...) is a special token that represents an ellipsis object. It is often used as a placeholder in code or data structures where + #you intend to fill in additional functionality or content later. + + #machine-level double precision floating point numbers + #Machine-level double precision floating-point numbers, often referred to as double, are a common representation of real numbers in computer systems. + #They are a binary format used to store and manipulate floating-point values with higher precision compared to single precision. + + #Callable types: + #callable types refer to objects that can be called as functions. These objects are capable of executing code when invoked with parentheses, just + #like a regular function. + + #cell_contents: + #the term "cell contents" refers to the value stored in a cell of a closure. A closure is a function object that retains references to variables + #in its enclosing lexical scope, even when the outer function has finished executing. + #When a closure is created, each variable it references is stored in a cell, which is an internal data structure associated with the closure. + #The cell contents refer to the value stored within the cell associated with a particular variable in a closure. It represents the value of the + #variable as seen by the closure, regardless of any changes made to the variable in the outer scope. + + #example for "When an instance method object is created by retrieving a user-defined function object from a class via one of its instances, + #its __self__ attribute is the instance, and the method object is said to be bound. The new method’s __func__ attribute is the original function + #object." +""""" +class MyClass: + def my_method(self): + print("Hello, world!") + +# Creating an instance of MyClass +my_instance = MyClass() + +# Retrieving the method object from the instance +method_object = my_instance.my_method + +# Accessing the attributes of the method object +print(method_object.__self__) # Output: <__main__.MyClass object at 0x...> +print(method_object.__func__) # Output: + +# Calling the method through the method object +method_object() # Output: Hello, world! +""""" + + #async def: + # the async def syntax is used to define an asynchronous function, also known as a coroutine. An asynchronous function allows concurrent. + # execution of multiple tasks by allowing the program to proceed to other tasks while waiting for certain operations to complete. +""""" +import asyncio + +async def my_coroutine(): + print("Coroutine started") + await asyncio.sleep(1) # Simulating an asynchronous operation + print("Coroutine completed") + +# Calling the coroutine +asyncio.run(my_coroutine()) +""""" + #Static method and class method: + #In Python, static methods and class methods are two types of methods that can be defined within a class. + #Static methods: + #Static methods are defined using the @staticmethod decorator or by declaring them inside the class without any special decorator. + #Static methods are not bound to a specific instance or the class itself. They behave like regular functions but are defined within the class for organizational purposes. + #Static methods do not have access to the instance or class attributes and cannot modify them directly. + #Static methods can be called on the class itself or on an instance of the class. + #Class methods: + #Class methods are defined using the @classmethod decorator. + #Class methods are bound to the class itself rather than the instances. They receive the class as the first argument (usually named cls) instead of the instance (self). + #Class methods have access to the class attributes and can modify them if needed. + #Class methods can be called on the class itself or on an instance of the class.