Pickling Pickling and unpickling are terms commonly used in the context of Python programming and refer to the process of serializing and deserializing objects. In simple terms, pickling is the process of converting a Python object into a byte stream, while unpickling is the process of converting the byte stream back into a Python object.…
NumPy arrays offer several advantages over nested lists in Python. Let’s see some of the key advantages: Overall, the advantages of NumPy arrays over nested lists make them an excellent choice for numerical computations, large datasets, and scientific computing tasks, providing performance improvements and ease of use. Popular Posts
Multithreading usually implies that multiple threads are executed concurrently. The Python Global Interpreter Lock doesn’t allow more than one thread to hold the Python interpreter at that particular point of time. So, multithreading in python is achieved through context switching. It is quite different from multiprocessing which actually opens up multiple across multiple threads. Popular…
Deepcopy Deepcopy creates a different object and populates it with the child objects of the original object. Therefore, changes in the original object are not reflected in the copy. copy.deepcopy() creates a Deep Copy. Shallow copy Shallow copy creates a different object and populates it with the references of the child objects within the original…
A literal in python source code represents a fixed value for primitive data types. There are 5 types of literals in Python- String literals A string literal is created by assigning some text enclosed in single of double quotes to a variable. To create multiline literals, assign the multiline text enclosed in triple quotes. E.g.,…
The common built-in data types in Python are: String A sequence of characters in called a string. They are declared within single or double-quotes. E.G., ‘Sana’, ‘she is going to the market’, etc. Set Sets are a collection of unique items that are not in order. e.g. {7, 6, 8}. Dictionary A dictionary stores values…
The common built-in data types in python are: Numbers They include integers, floating-point numbers, and complex numbers. e.g., 1, 2.4, 3 + 4j List An ordered sequences of items is called a list. The elements of a list belong to different data types. Eg. [5, ‘player’, 4.7]. Tuple It is also an ordered sequence of…
Dictionary and list comprehensions are just concise way to define dictionaries and lists. Example of list comprehension is: Var = [i for i in range (5)] The above code created a list as below- [0, 1, 2, 3, 4] Example of dictionary comprehension is – X = [i : i + 2 for I in…
A namespace In Python refers to the name which is assigned to each object in Python. The objects are variables and functions. As each object is created, its name along with space (the address of the outer function in which the object is), gets created. The namespaces are maintained in Python like a dictionary where…
The difference between copy and view Copy View Join & split function Join array – joining means putting contents of two or more array in a single array. hstack vs vstack The major difference is that np.hstack combines NumPy arrays horizontally and np.vstack combines arrays vertically. Split – splitting breaks one array into multiple. NumPy…
Broadcasting NumPy Arrays The term broadcasting describes how NumPy treats arrays with different shapes during arithmetic operations. Subject to certain constraints, the smaller array is “broadcast” across the larger array in order that they have compatible shapes. NumPy operations are usually done on pairs of arrays on an element-by-element basis. Within the simplest case, the…