Articles on Trending Technologies

Technical articles with clear explanations and examples

Python Binary Data Services

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 479 Views

The struct module in Python provides functionality for converting between C structs and Python bytes objects. This is essential for binary data processing, file format handling, and network protocol implementation. Format String Characters The byte order, size, and alignment in format strings are controlled by these characters ? Character Byte order Size Alignment @ native native native = native standard none big-endian standard none ! network (= big-endian) standard none Data Type Format Characters These format characters map ...

Read More

Python import modules from Zip archives (zipimport)

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 2K+ Views

The zipimport module allows Python to import modules and packages directly from ZIP archives. This feature is useful for distributing Python applications as single ZIP files or organizing multiple modules in a compressed format. Creating a ZIP Archive First, let's create a ZIP archive containing Python modules. We'll use the zipfile module to compress multiple Python files ? import zipfile import os # Create some sample Python files first with open('hello.py', 'w') as f: f.write('def greet(name): return f"Hello, {name}!"print(greet("World"))') with open('math_utils.py', 'w') as f: ...

Read More

Python class browser support

Arjun Thakur
Arjun Thakur
Updated on 25-Mar-2026 384 Views

The pyclbr module in Python's standard library extracts information about functions, classes, and methods defined in a Python module. The information is extracted from the Python source code rather than by importing the module, making it safe for analyzing potentially problematic code. readmodule() Function The readmodule() function returns a dictionary mapping module-level class names to class descriptors. It takes a module name as parameter and may include modules within packages ? import pyclbr mod = pyclbr.readmodule("socket") def show(c): s = "class " + c.name print(s + ...

Read More

Byte-compile Python libraries

Chandu yadav
Chandu yadav
Updated on 25-Mar-2026 984 Views

Python is an interpreter-based language that internally compiles source code to bytecode when a script is executed. While bytecode is automatically removed for scripts, imported modules create .pyc files in the __pycache__ folder for faster subsequent imports. You can also explicitly byte-compile Python files using the py_compile module. What is Byte Compilation? When Python imports a module, it automatically creates a compiled bytecode version with .pyc extension. This bytecode loads faster than parsing the original .py file. The py_compile module allows you to create these bytecode files manually without running or importing the code. Command Line Compilation ...

Read More

Trace or track Python statement execution (trace)

George John
George John
Updated on 25-Mar-2026 6K+ Views

The trace module in Python provides powerful tools for monitoring program execution, generating coverage reports, and tracking function calls. It helps developers debug code by showing which lines execute and how many times. Example Files Setup Let's create two Python files to demonstrate the trace module features ? myfunctions.py #myfunctions.py import math def area(x): a = math.pi * math.pow(x, 2) return a def factorial(x): if x == 1: return 1 ...

Read More

Python Low-level threading API

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 713 Views

The _thread module in Python provides a low-level interface for working with lightweight processes having multiple threads sharing a global data space. For synchronization, simple locks (also called mutexes or binary semaphores) are defined in this module. The threading built-in module provides a higher-level threading API built on top of this module. start_new_thread() Function This module-level function is used to open a new thread in the current process. The function takes a function object as an argument. This function gets invoked on successful creation of the new thread. The span of this function corresponds to the lifespan of ...

Read More

Python bootstrapping the pip installer

Arjun Thakur
Arjun Thakur
Updated on 25-Mar-2026 805 Views

The ensurepip module provides support for bootstrapping the pip installer in existing Python installations. While pip is included by default since Python 3.4, there are cases where you might need to install it manually using ensurepip. Why Use ensurepip? The ensurepip module is useful when: pip installation was skipped during Python installation You created a virtual environment without pip pip needs to be reinstalled or upgraded Creating Virtual Environment Without pip You can create a virtual environment that excludes pip using the --without-pip option ? python -m venv --without-pip testenv ...

Read More

Why is Python slower than other languages?

Dev Kumar
Dev Kumar
Updated on 25-Mar-2026 2K+ Views

Python is generally slower than compiled languages like C/C++ due to fundamental differences in how code is executed. While Python prioritizes ease of use and development speed, languages like C are designed for maximum runtime performance. Interpreted vs Compiled Languages The primary reason for Python's slower execution is that it's an interpreted language, while C/C++ are compiled languages. Here's how they differ ? Python (Interpreted) # This code is interpreted line by line at runtime def calculate_sum(numbers): total = 0 for num in numbers: ...

Read More

Disassembler for Python bytecode

Anvi Jain
Anvi Jain
Updated on 25-Mar-2026 3K+ Views

The dis module in Python's standard library provides functions for analyzing Python bytecode by disassembling it into human-readable form. This helps with code optimization and understanding how Python executes your code internally. Basic Disassembly with dis() The dis() function generates a disassembled representation of Python code objects like functions, methods, or classes − import dis def hello(): print("hello world") dis.dis(hello) 2 0 LOAD_GLOBAL ...

Read More

Python Functions creating iterators for efficient looping

Nikitasha Shrivastava
Nikitasha Shrivastava
Updated on 25-Mar-2026 352 Views

In this article, we will talk about creating iterators for efficient looping in Python functions. An iterator is an object that helps you go through all items one by one, like reading pages of a book sequentially. In Python, we can use lists, tuples, dictionaries, and sets as iterables. Let's explore Python functions that generate iterators for efficient looping and memory management. What are Iterators? An iterator is an object that implements the iterator protocol, consisting of __iter__() and __next__() methods. Iterators are memory-efficient because they generate values on demand rather than storing all values in memory ...

Read More
Showing 7151–7160 of 61,303 articles
« Prev 1 714 715 716 717 718 6131 Next »
Advertisements