✨ Python Inner Functions: What Are They Good For? ✨
📖 Learn how to create inner functions in Python to access nonlocal names, build stateful closures, and create decorators.
🏷️ #intermediate #python
📖 Learn how to create inner functions in Python to access nonlocal names, build stateful closures, and create decorators.
🏷️ #intermediate #python
❤1👎1
This channels is for Programmers, Coders, Software Engineers.
0️⃣ Python
1️⃣ Data Science
2️⃣ Machine Learning
3️⃣ Data Visualization
4️⃣ Artificial Intelligence
5️⃣ Data Analysis
6️⃣ Statistics
7️⃣ Deep Learning
8️⃣ programming Languages
✅ https://news.1rj.ru/str/addlist/8_rRW2scgfRhOTc0
✅ https://news.1rj.ru/str/Codeprogrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
❤2
✨ dependency | Python Glossary ✨
📖 An external package that your project needs in order to run, build, or be developed.
🏷️ #Python
📖 An external package that your project needs in order to run, build, or be developed.
🏷️ #Python
An incredibly short book, but with a deep analysis of the internal mechanisms of Python, which we use every day. ❤️
Each chapter contains an explanation of a specific language feature, such as working with *args/**kwargs, mutable arguments, generators, decorators, context managers, enumerate/zip, exceptions, dunder methods, and other clever constructs.
Link: https://book.pythontips.com/en/latest/
👉 @DataScience4
Each chapter contains an explanation of a specific language feature, such as working with *args/**kwargs, mutable arguments, generators, decorators, context managers, enumerate/zip, exceptions, dunder methods, and other clever constructs.
Link: https://book.pythontips.com/en/latest/
Please open Telegram to view this post
VIEW IN TELEGRAM
❤7
Forwarded from Machine Learning with Python
Real Python.pdf
332 KB
Real Python - Pocket Reference (Important)
#python #py #PythonTips #programming
https://news.1rj.ru/str/CodeProgrammer🩵
#python #py #PythonTips #programming
https://news.1rj.ru/str/CodeProgrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
❤6
Tip: Efficiently Slice Iterators and Large Sequences with
Explanation:
Traditional list slicing (
Example:
━━━━━━━━━━━━━━━
By: @DataScience4 ✨
itertools.isliceExplanation:
Traditional list slicing (
my_list[start:end]) creates a new list in memory containing the sliced elements. While convenient for small lists, this becomes memory-inefficient for very large lists and is impossible for pure iterators (like generators or file objects) that don't support direct indexing.itertools.islice provides a memory-optimized solution by returning an iterator that yields elements from a source iterable (list, generator, file, etc.) between specified start, stop (exclusive), and step indices, without first materializing the entire slice into a new collection. This "lazy" consumption of the source iterable is crucial for processing massive datasets, infinite sequences, or streams where only a portion is needed, preventing excessive memory usage and improving performance. It behaves syntactically similar to standard slicing but operates at the iterator level.Example:
import itertools
import sys
# A generator for a very large sequence
def generate_large_sequence(count):
for i in range(count):
yield f"Data_Item_{i}"
# Imagine needing to process only a small segment of 10 million items
total_items = 10**7
data_stream = generate_large_sequence(total_items)
# Get items from index 500 to 509 (inclusive)
# Using islice:
print("--- Using itertools.islice ---")
# islice(iterable, [start], stop, [step])
# Here, start=500, stop=510 (exclusive)
for item in itertools.islice(data_stream, 500, 510):
print(item)
# Compare memory usage (conceptual, as actual list materialization would be massive)
# If you tried:
# large_list = list(generate_large_sequence(total_items)) # <-- HUGE memory consumption here!
# for item in large_list[500:510]:
# print(item)
# islice consumes minimal memory, only holding iterator state.
# The `data_stream` generator itself only holds its current state, not the whole sequence.
print("\n`itertools.islice` memory footprint is negligible compared to creating a full list slice.")
━━━━━━━━━━━━━━━
By: @DataScience4 ✨
❤2
I just discovered
No more dragging wires around in inconvenient GUIs.
Clean code for resistors, logic elements, and much more.
Full customization of all elements.
👉 @DataScience4
schemdraw — a Python library that turns code into neat and clear electrical schematics.No more dragging wires around in inconvenient GUIs.
Clean code for resistors, logic elements, and much more.
Full customization of all elements.
pip install schemdraw and you can start drawing.Please open Telegram to view this post
VIEW IN TELEGRAM
❤1
✨ isort | Python Tools ✨
📖 A command-line utility and library for sorting and organizing Python imports.
🏷️ #Python
📖 A command-line utility and library for sorting and organizing Python imports.
🏷️ #Python