Better HN
topnewbestaskshowjobs
Log inSign up

Suor

614 karma · joined Oct 26, 2011 (15y ago) · 68 submissions

Submissions

comment 2w ago · link · parent

There is a small research in the end whether coding agents benefit from it

2.

Asserts You Can Read at a Glance(blog.hackflow.ru ↗)

1 points · by Suor · 2w ago · 1 comment

3.

[No] Use for Humans in the Age of AI(blog.hackflow.ru ↗)

3 points · by Suor · 1mo ago · discuss

comment 3y ago · link · parent

Writing things directly is tightly coupling code. Sometimes quite distant portions of it, i.e. database access and presentation logic. With ORM and some smarter lazy technics or introspection at least you can untie it, with hand written SQL there is no way. And the reason is strings are poorly composable. Unless you use some query generator, but then we are back to ORM-like something.

comment 3y ago · link · parent

Never used this, but I see that it provides a context manager/decorator, which you can use to "shield" any code. And also some shortcuts for DjangoREST or something.

Regarding extra code, you can simply replace the Djangos' `render()`, with the one from this lib and you are done. I would have probably made a custom template extension or something to do that for all renders automatically though too.

comment 3y ago · link · parent

cacheops is more of a general purpose ORM caching with automatic invalidation.

comment 3y ago · link · parent

For that fetching in chunks is usually a way to go. I use something of these usually https://handy.readthedocs.io/en/latest/db.html#queryset_iter...

comment 3y ago · link · parent

GraphQL makes it even more fun :)

comment 3y ago · link · parent

I usually use `.values()` and `.values_list()` only when model creation is really slow. Usually many rows fetched.

comment 3y ago · link · parent

Actually there is such thing already https://pypi.org/project/django-auto-prefetch/ Not a monkey patch though, so will only work on the models you inherit from this.

comment 3y ago · link · parent

Here is an example of such thing https://github.com/Suor/django-cacheops/blob/8b3a79de29b2545...

comment 3y ago · link · parent

Should be easy enough to implement. You only need a context manager that adds 1 to some threadlocal flag on enter and subrracts on exit then check this flag in the monkey patch. Not sure how costly that will be though.

comment 3y ago · link · parent

cacheops can do the same, but it never came to my mind to actually go this way. I would rather write some special code to fetch with `id__in=[...]` and then cache individually.

comment 3y ago · link · parent

HN keeps automatically replacing the URL. It used to be a redirect before, but not anymore

comment 3y ago · link · parent

Thanks

16.

Ban 1+N in Django(suor.github.io ↗)

175 points · by Suor · 3y ago · 148 comments

17.

Show HN: A Cheatsheet for funcy sequence, collections and functional stuff(funcy.readthedocs.io ↗)

9 points · by Suor · 10y ago · 1 comment

18.

Async decorators and combinators for Node.js(npmjs.com ↗)

1 points · by Suor · 11y ago · discuss

19.

Practical Python to JavaScript Translation(hackflow.com ↗)

1 points · by Suor · 11y ago · discuss

20.

Show HN: Sublime Text move around and reform code demo(hackflow.com ↗)

7 points · by Suor · 11y ago · discuss

21.

Python Metaprogramming Beyond Decency(hackflow.com ↗)

2 points · by Suor · 11y ago · discuss

comment 11y ago · link · parent

Using framework has its cost, so you can be better of if you understand clearly what you are doing. OTOH, framework brings structure so it's less probable you skrew up your design.

comment 11y ago · link · parent

There are sure some things I haven't covered. The major one is components, which make a big deal in factor, reuse and composition. But the post started to be too long and loosing point so I skipped it.

There are also ideas beyond React I left aside. I will probably write some follow up post later.

comment 11y ago · link · parent

I've already emailed there, won't make a difference probably anyway. I hate this HN tricky rating, one my post got dumped from top 5 cause there were too many comments!

Reddit kind of saves the day :)

comment 11y ago · link · parent

I announced on twitter and posted to reddit. Is this prohibited?

comment 11y ago · link · parent

Maybe english?
123