Virtual environments and system packages

Back to list2024-02-27
You

Should the venv see system site-packages?

ChatGPT

No, except when you deliberately depend on a system build of something heavy like GTK bindings. Inheriting site-packages is the most common source of "works on my machine", because the environment is no longer described by requirements alone.

Tool steps: 3 (reasoning summary, call to python, execution output)
reasoning summary
Checked the query plan, then compared index options.
call to python
rows = run_sql("EXPLAIN (ANALYZE) SELECT ...")
print(rows[:3])
execution output
Seq Scan on events  (cost=0.00..812431.00 rows=41203122 width=16)
  Rows Removed by Filter: 38996878
Planning Time: 0.214 ms
Execution Time: 11842.663 ms
You
latency-before-after.png
You

How specific should except clauses be?

ChatGPT

Specific enough that an unexpected failure still crashes. except Exception around an entire request handler is fine if it logs and re-raises in development; the same clause around three lines of parsing will swallow the typo that broke them.