What is the difference between Cython and CPython?

AmitDiwan
Updated on 25-Mar-2026 06:01:18

9K+ Views

Python has multiple implementations, with CPython being the default interpreter and Cython being a superset language that compiles to C. Understanding their differences helps choose the right tool for your project. What is CPython? CPython is the reference implementation of Python written in C. It's the standard Python interpreter that most developers use daily. CPython interprets Python code at runtime, converting it to bytecode and then executing it on the Python Virtual Machine. Example A simple Python program running on CPython − def fibonacci(n): if n

Difference between mutable and immutable in python?

Sri
Sri
Updated on 25-Mar-2026 06:00:58

3K+ Views

Python defines variety of data types of objects. These objects are stored in memory and object mutability depends upon the type. Mutable objects like Lists and Dictionaries can change their content without changing their identity. Immutable objects like Integers, Floats, Strings, and Tuples cannot be modified after creation. Mutable Objects - Lists Lists are ordered collections that can be modified after creation. You can change individual elements, add new items, or remove existing ones ? # Creating a list of numbers numbers = [1, 2, 3, 4, 5] print("Original list:", numbers) # Modifying an element ... Read More

What is calendar module in python?

AmitDiwan
Updated on 25-Mar-2026 06:00:35

4K+ Views

The calendar module in Python provides functions to display calendars and perform calendar-related operations. By default, these calendars have Monday as the first day of the week and Sunday as the last. Display the Calendar of an Year To display the calendar of an year, use the calendar() method and set year as the parameter − import calendar # Set the year year = 2022 # Display the calendar print(calendar.calendar(year)) The output of the above code is − ... Read More

Interpreter base classes in Python

Rishi Raj
Updated on 25-Mar-2026 06:00:08

602 Views

Python's interactive mode works on the principle of REPL (Read - Evaluate - Print - Loop). The code module in Python's standard library provides classes and convenience functions to set up REPL environment from within Python scripts. Core Classes in the Code Module The code module defines two main classes: InteractiveInterpreter: This class deals with parsing and interpreter state (the user's namespace). InteractiveConsole: Closely emulates the behavior of the interactive Python interpreter and is a subclass of InteractiveInterpreter. Convenience Functions interact(): Convenience function to run a read-eval-print loop. compile_command(): Useful for programs that ... Read More

Package extension utility in Python

Vikyath Ram
Updated on 25-Mar-2026 05:59:46

835 Views

The pkgutil module in Python provides utilities for extending and working with Python packages. It allows you to modify the module search path, load resources from packages, and iterate through available modules. extend_path() Function The extend_path() function extends the search path for modules within a package. It's commonly used in a package's __init__.py file ? import pkgutil # This would typically be in a package's __init__.py file __path__ = pkgutil.extend_path(__path__, __name__) print("Extended package path:", __path__) The function scans sys.path for directories containing subdirectories named after your package and combines them into a single ... Read More

zipapp - Manage executable Python zip archives

Arushi
Updated on 25-Mar-2026 05:59:19

804 Views

The zipapp module was introduced in Python 3.5 to manage executable Python zip archives. This module allows you to package Python applications into a single executable .pyz file that can be run directly by the Python interpreter. Creating a Basic Executable Archive To create an executable archive, you need a directory containing Python code with a main function. Let's create a simple example ? First, create a directory called myapp and add an example.py file: def main(): print('Hello World') if __name__ == '__main__': main() ... Read More

Access to the underlying platform's identifying data in Python

Arushi
Updated on 25-Mar-2026 05:58:59

350 Views

The platform module in Python provides functions to access information about the underlying system's hardware, operating system, and interpreter version. This is useful for system administration, debugging, and creating platform-specific code. Basic System Information architecture() This function queries the given executable (defaults to the Python interpreter executable) for various architecture information − import platform print(platform.architecture()) ('64bit', '') machine() This function returns the machine type, e.g. 'i386'. An empty string is returned if the value cannot be determined − import platform print(platform.machine()) x86_64 ... Read More

Short Circuiting Techniques in Python?

Chandu yadav
Updated on 25-Mar-2026 05:58:36

2K+ Views

Short-circuiting is an optimization technique where Python stops evaluating boolean expressions as soon as the result is determined. This behavior can be confusing for beginners but is essential for writing efficient code. Understanding the Confusion New programmers often misunderstand how and and or operators work. Let's examine these expressions ? print('x' == ('x' or 'y')) print('y' == ('x' or 'y')) print('x' == ('x' and 'y')) print('y' == ('x' and 'y')) True False False True How OR Short-Circuiting Works With or, Python evaluates the first value. If it's truthy, Python returns ... Read More

NZEC error in Python?

Arjun Thakur
Updated on 25-Mar-2026 05:58:14

988 Views

NZEC (Non-Zero Exit Code) is a runtime error that occurs when a Python program terminates abnormally. Exit codes are numbers returned by programs to the operating system - 0 indicates successful termination, while non-zero codes indicate errors. What Causes NZEC Error? NZEC errors commonly occur due to: Incorrect input handling − Not properly parsing input format Array index errors − Accessing negative or out-of-bounds indices Memory overflow − Using more memory than allocated Infinite recursion − Running out of stack memory Division by zero − Basic arithmetic errors Integer overflow − Values exceeding variable limits ... Read More

Line detection in python with OpenCV?

Ankith Reddy
Updated on 25-Mar-2026 05:57:53

4K+ Views

In this article, we will learn how to detect lines in an image using the Hough Transform technique with OpenCV in Python. What is Hough Transform? Hough Transform is a feature extraction method used to detect simple geometric shapes in images. It can identify shapes even if they are broken or slightly distorted, making it particularly useful for line detection in computer vision applications. A "simple" shape is one that can be represented by only a few parameters. For example: A line requires two parameters: slope and intercept A circle requires three parameters: center coordinates ... Read More

Advertisements