VIP 👤
🏠 Startseite
Vergleiche
📊 Alle Benchmarks 🦖 Dinosaurier v1 🦖 Dinosaurier v2 ✅ To-Do-Listen-Apps 🎨 Kreative freie Seiten 🎯 FSACB - Ultimatives Showcase 🌍 Übersetzungs-Benchmark
Modelle
🏆 Top 10 Modelle 🆓 Kostenlose Modelle 📋 Alle Modelle ⚙️ Kilo Code
Ressourcen
💬 Prompt-Bibliothek 📖 KI-Glossar 🔗 Nützliche Links 🔌 KI-APIs & Router
Medium

Refactor Legacy Python Code

#coding #python #optimization

Improve the efficiency and readability of a provided Python code snippet by applying Pythonic idioms.

You are an expert Python developer. Please review the following code snippet. Identify any performance bottlenecks, readability issues, or anti-patterns. Refactor the code to be more efficient using Pythonic idioms, add docstrings where necessary, and explain the changes you made in a list format. Code snippet: def get_primes(n): primes = [] for num in range(2, n + 1): for i in range(2, num): if (num % i) == 0: break else: primes.append(num) return primes