Better HN
topnewbestaskshowjobs
Log inSign up

adamchainz

33 karma · joined Nov 10, 2012 (14y ago) · 19 submissions

[ my public key: https://keybase.io/adamchainz; my proof: https://keybase.io/adamchainz/sigs/gtiWWj6v-5ZX76r1sRsn3mNjviNuuPIREp_8274cCTo ]
Submissions

comment 10mo ago · link · parent

OP here. Thanks.

Yeah, profilers are very varied in Python, and none are super easy. I often use either cProfile + pstats (per this post: https://adamj.eu/tech/2025/05/20/python-quick-cprofile-recip...), cProfile + gprof2dot (per this post: https://adamj.eu/tech/2024/03/23/django-optimizing-system-ch... ) or py-spy. I'm excited for "tachyon", the sampling profiler coming in Python 3.15.

comment 10mo ago · link · parent

Oh cool! Do you have any code for that? Sounds super useful for projects like Django…

comment 11mo ago · link · parent

django-tasks is the reference implementation for django.tasks, by the same author. It's up for discussion if and when the DatabaseBackend gets merged, and it seems likely to me that a Redis-based backend would be suggested at some point. It takes time and energy though!

comment 11mo ago · link · parent

OP here, thanks for the praise!

Yeah, I mentioned Celery due to its popularity, no other reason ;)

comment 3y ago · link · parent

Yeah, that is odd. Python still has no immutable dict type, except it kinda does: https://adamj.eu/tech/2022/01/05/how-to-make-immutable-dict-...

comment 3y ago · link · parent

Within the function, args is a tuple, as your output demonstrates.

comment 4y ago · link · parent

Unfortunately that prevents Mypy from loading the type hints for 'markdown'

    from types import ModuleType

    markdown: ModuleType | None

    try:
        import markdown  # type: ignore [no-redef]
    except ImportError:
        markdown = None

    if markdown is not None:
        reveal_type(markdown.markdown)
Running Mypy:

    example.py:11: note: Revealed type is "Any"
Whereas when correctly imported:

    example.py:3: note: Revealed type is "def (text: builtins.str, *, extensions: Union[typing.Sequence[Union[builtins.str, markdown.extensions.Extension]], None] =, extension_configs: Union[typing.Mapping[builtins.str, typing.Mapping[builtins.str, Any]], None] =, output_format: Union[Literal['xhtml'], Literal['html'], None] =, tab_length: Union[builtins.int, None] =) -> builtins.str"

comment 4y ago · link · parent

Ah yes, nice hint that backports can use sys.version_info.

comment 4y ago · link · parent

It will work but Mypy won't know to use the type hints for the markdown module.

10.

2nd Edition of Data Science at the Command Line Released (Free)(datascienceatthecommandline.com ↗)

6 points · by adamchainz · 4y ago · 1 comment

comment 5y ago · link · parent

Here’s my post summarizing new testing features in Django 4.0: https://adamj.eu/tech/2021/09/28/new-testing-features-in-dja...

comment 6y ago · link · parent

Great news. Have been watching for a while and looking forward to using it now that it's fully released.

comment 6y ago · link · parent

Awesome, basically a free book chapter. Will definitely fire up the notebook and give this a try.

comment 7y ago · link · parent

I learnt a lot from the book Data Science at the Command Line, now free and online at https://www.datascienceatthecommandline.com/

15.

Upgrading to Python 3 with Zero Downtime(tech.yplanapp.com ↗)

2 points · by adamchainz · 10y ago · discuss

16.

Deploying Amazon Lambda Functions with Ansible(tech.yplanapp.com ↗)

5 points · by adamchainz · 10y ago · discuss

17.

Show HN: Python function patching (not monkey patching, actual patch-patching)(github.com ↗)

6 points · by adamchainz · 11y ago · 1 comment

18.

Building a Better DatabaseCache for Django on MySQL(adamj.eu ↗)

2 points · by adamchainz · 11y ago · discuss