HN user

genericlemon24

2,296 karma
Posts145
Comments36
View on HN
www.wheresyoured.at 14d ago

Let AI Burn

genericlemon24
28pts6
infrequently.org 15d ago

Abject Praise

genericlemon24
24pts22
death.andgravity.com 1mo ago

Ordered Key Sharding in DynamoDB

genericlemon24
4pts0
berthub.eu 1mo ago

EU and Civil Society Need to Progress on Digital Autonomy

genericlemon24
5pts0
berthub.eu 2mo ago

The Impossible Things We Have to Believe

genericlemon24
2pts0
infrequently.org 3mo ago

The Web Is an Antitrust Wedge

genericlemon24
6pts0
berthub.eu 7mo ago

The European Cloud Situation at the end of 2025

genericlemon24
6pts3
simonwillison.net 7mo ago

I ported JustHTML from Python to JavaScript with LLMs in 4.5 hours

genericlemon24
1pts0
tonsky.me 7mo ago

How to Get Hired in 2025

genericlemon24
52pts14
lucumr.pocoo.org 10mo ago

996

genericlemon24
1058pts532
berthub.eu 11mo ago

Chatcontrol 2025 Edition in Brief

genericlemon24
6pts0
www.lastweekinaws.com 12mo ago

The Vendor Lock-In You Don't See

genericlemon24
3pts0
death.andgravity.com 12mo ago

Inheritance over Composition, Sometimes

genericlemon24
2pts0
berthub.eu 1y ago

'Going to the cloud' could also mean locking into a forever sub-contractor

genericlemon24
20pts4
htmx.org 1y ago

Architectural Sympathy

genericlemon24
2pts0
www.scottsmitelli.com 1y ago

Shut Up and Dance

genericlemon24
1pts0
death.andgravity.com 1y ago

ProcessThreadPoolExecutor: when I/O becomes CPU-bound

genericlemon24
4pts1
blog.startifact.com 2y ago

JavaScript: When you need two ways to do it

genericlemon24
2pts1
blog.glyph.im 2y ago

Bilithification

genericlemon24
4pts1
qntm.org 2y ago

The Assist

genericlemon24
1pts0
medium.com 2y ago

Backpressure explained – the resisted flow of data through software (2019)

genericlemon24
107pts45
ar.al 2y ago

Streaming HTML

genericlemon24
3pts0
pyfound.blogspot.com 2y ago

White House recommends use of memory-safe languages like Python

genericlemon24
1pts0
infrequently.org 2y ago

Home Screen Advantage

genericlemon24
330pts226
blog.glyph.im 2y ago

Safer, Not Later

genericlemon24
3pts0
death.andgravity.com 2y ago

Building a priority-expiry LRU cache without heaps or trees in Python

genericlemon24
1pts0
berthub.eu 2y ago

Taking the Airbus to the IKEA Cloud

genericlemon24
1pts0
www.sqlite.org 2y ago

SQLite 3.45 released with JSONB support

genericlemon24
321pts64
peps.python.org 2y ago

PEP 738: Adding Android as a supported platform

genericlemon24
2pts0
peps.python.org 2y ago

PEP 736: Shorthand syntax for keyword arguments at invocation

genericlemon24
1pts0

Glad to hear that :D One of my main goals was to show the entire progression of how I approached the problem, instead of just saying "here's the final result".

I have another article that covers profiling in more detail, you might find it useful: https://death.andgravity.com/fast-conway-cubes#intro-to-prof...

Note that besides the cProfile text output, there are better, graphical tools for profiling; I've personally used pyflame+flamegraph.pl, and tuna.

I actually did try this, but I got impatient and stopped it after 30 minutes or so, and a ~20G database file.

For some reason, after that, `ls` in that directory (or even shell completion) would freeze the shell entirely, even after reboot. I eventually managed to delete the file with `rm db.sqlite` (no completion allowed), but even that took like 2 minutes.

I might try again with WAL enabled (based on my shell history, I also deleted a -journal file).

For one, it can output more than one flavor of SQL: https://pypika.readthedocs.io/en/latest/3_advanced.html#hand...

Since SQL is ever-so-slightly different across databases, I imagine trying to cover all of them as a single dev is a nightmare (especially if that's not the problem you're trying to solve).

I wrote my own query builder because I know for sure I'm only targeting SQLite. The second I need my feed reader library to work with another database engine I'm dumping my own for something more serious – either a full blown database abstraction layer like SQLAlchemy or Peewee (likely without the ORM part), or something simpler like PyPika or python-sql.[1]

[1]: I talk more about them here: https://death.andgravity.com/own-query-builder#sqlbuilder-py...

It's magic when it works but it suffers from the drawbacks noted elsewhere in the thread about traditional ORMS...

(Not that there are lots of other devs on my project at the moment, but)

I am managing this by aggressively limiting the size / features of my query builder, so it's (relatively) easy to understand just by looking at the code.

If it ever passes that point, it's probably time to switch to a "real" query builder / ORM.

That's what the fancier __init__() at the end of the article[1] is for :)

Here's the tl;dr of a real-world example[2]:

    query = Query().SELECT(...).WHERE(...)
    for subtags in tags:
        tag_query = BaseQuery({'(': [], ')': ['']}, {'(': 'OR'})
        tag_add = partial(tag_query.add, '(')
        for subtag in subtags:
            tag_add(subtag)
        query.WHERE(str(tag_query))
It can be shortened by making a special subclass, but I only needed this once or twice so I didn't bother yet:
    for subtags in tags:
        tag_query = QList('OR')
        for subtag in subtags:
            tag_query.append(subtag)
        query.WHERE(str(tag_query))

[1]: https://death.andgravity.com/query-builder-how#more-init

[2] https://github.com/lemon24/reader/blob/10ccabb9186f531da04db...

What does `query.SELECT("one")` on its own represent?

data['SELECT'].append('one')

I'm intentionally trying to not depart too much from SQL / list-of-strings-for-each-clause model, since I'd have to invent/learn another one.

For a full-blown query builder, I agree Table("table").select("one") is better.

(author here)

Yup, good thing to note, thank you!

I've kinda assumed everyone knows about the named parameters some bindings offer, but that's probably not true. Will add a disclaimer.

In the previous articles, I do talk about how this is an upgrade from plain SQL, not from regular full-blown query builders / ORMs.