this post was submitted on 29 Apr 2024
33 points (100.0% liked)

Python

6160 readers
14 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 3 months ago

I discover the operator module! Amazing! 🤩

The operator Module A third alternative to writing lambda functions is to use the standard library’s operator module. This module contains some predefined functions and function factories, which can replace the most common use cases for lambda functions. Let’s look at both of these separtaely, factories first. Another note: the function that attrgetter returns is implemented in C, so it’s slightly faster than using either a normal or lambda function.

Useful if you want to speed up your code.