funcy
django-auto-prefetching
Our great sponsors
funcy | django-auto-prefetching | |
---|---|---|
5 | 1 | |
3,263 | 227 | |
- | - | |
5.5 | 4.6 | |
6 days ago | 5 months ago | |
Python | Python | |
BSD 3-clause "New" or "Revised" License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
funcy
- Funcy: Fancy and practical functional tools [Python]
- Ask HN: How can I get better at writing production-level Python?
-
Ban 1+N in Django
On an unrelated note, Python folks should check out OP's library funcy [1]: "A collection of fancy functional tools focused on practicality. Inspired by clojure, underscore and my own abstractions."
Thanks for the library Suor!
-
What can you do in Haskell that you can't do in Python(for example)?
Functional semantics are available in Python, but IMO not that great. List, dict, and generator comprehensions allow you to perform most operations that you would use in a functional first programming language and there are third party libraries like toolz and funcy that implement some of the more advanced operations. The main issue I've found with using Python as a functional language is it doesn't support fluent syntax. With Scala you can do a relatively complex map/filter/reduce operation with syntactic ease list_of_ints.map(x => x*x).filter(x => x%2 ==0).reduce(x,y => x+y) With Python it's just clunky and less readable b/c of support of list comprehension syntax over fluent syntax. sum([x**2 for x in list_of_ints if x % 2 == 0]) A codebase with 5000 lines of the Scala style code will be much readable and maintainable than with the Python style code.
-
Toolz - A functional standard library for Python
Also worse looking at: https://github.com/suor/funcy
django-auto-prefetching
-
Ban 1+N in Django
Shameless plug - I ran into this while developing REST interfaces with Django and built django-auto-prefetching: https://github.com/GeeWee/django-auto-prefetching
It essentially travels your DRF serializer tree and builds an auto-prefetched query automatically without you needing to do any work.
Back when I still worked actively on it, I wanted to monkey-patch models to track whether or not n+1 was happening, and if it was, automatically do pre-fetching, so instead of an n+1 problem you'd end up with just a "3-4 queries when it could've been 1" problem - which is much more palatable. Never got around to that part though.
What are some alternatives?
Toolz - A functional standard library for Python.
pellet - Pellet helps improve your Django app performance by discovering N+1 queries.
fn.py - Functional programming in Python: implementation of missing features to enjoy FP
django-zen-queries - Explicit control over database query execution in Django applications
CyToolz - Cython implementation of Toolz: High performance functional utilities
nplusone - Auto-detecting the n+1 queries problem in Python
Pyrsistent - Persistent/Immutable/Functional data structures for Python
django-orm-plus
Coconut - Simple, elegant, Pythonic functional programming.
django-seal - Django application providing queryset sealing capability.
Deal - 🤝 Design by contract for Python. Write bug-free code. Add a few decorators, get static analysis and tests for free.
django-cacheops - A slick ORM cache with automatic granular event-driven invalidation.