News for hackers. Stuff that matters.
Re:12 requests per second: A realistic look at Python web fr... by rglullis on Friday February 19, 2021 @06:56AM (#26192155)
Maybe I spent too much time with Django already, but if I see anyone doing anything but Book.objects.values_list('author__name', flat=True) for this type of expression, I would mark it as a 3x WTF? in the code review.
Re:12 requests per second: A realistic look at Python web fr... by DangitBobby on Friday February 19, 2021 @05:55PM (#26199129)
As written, it's obvious you should be doing something else like `values()` or `values_list()`. You're much more likely to fall victim to this anti-pattern if it's done within a standard for-loop that has a bunch of other stuff going on. I just wrote it as a list comprehension to avoid having to muck about with formatting on my phone.
Re:12 requests per second: A realistic look at Python web fr... by acdha on Friday February 19, 2021 @09:24AM (#26193449)
I’d also allow prefetch_related if you’re using more than the most trivial data - no point in duplicating logic you have in your models if you have a method which generates something like a name, URL, etc. based on multiple fields.