HNHacker News
TopNewBestAskShowJobs

adamchainz

33 karma · joined November 10, 2012

[ my public key: https://keybase.io/adamchainz; my proof: https://keybase.io/adamchainz/sigs/gtiWWj6v-5ZX76r1sRsn3mNjviNuuPIREp_8274cCTo ]
submissionscomments
adamchainz··on Python: Tprof, a Targeting Profiler
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.

adamchainz··on Python: Tprof, a Targeting Profiler
Oh cool! Do you have any code for that? Sounds super useful for projects like Django…
adamchainz··on Django: what’s new in 6.0
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!
adamchainz··on Django: what’s new in 6.0
OP here, thanks for the praise!

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

adamchainz··on Python Type Hints – *args and **kwargs (2021)
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-...
adamchainz··on Python Type Hints – *args and **kwargs (2021)
Within the function, args is a tuple, as your output demonstrates.
adamchainz··on Python Type Hints – How to Handle Optional Imports
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"
adamchainz··on Python Type Hints – How to Handle Optional Imports
Ah yes, nice hint that backports can use sys.version_info.
adamchainz··on Python Type Hints – How to Handle Optional Imports
It will work but Mypy won't know to use the type hints for the markdown module.
adamchainz··on Django 4.0 release candidate 1 released
Here’s my post summarizing new testing features in Django 4.0: https://adamj.eu/tech/2021/09/28/new-testing-features-in-dja...
adamchainz··on htmx – high power tools for HTML - v1.0.0 Release
Great news. Have been watching for a while and looking forward to using it now that it's fully released.
adamchainz··on Plotnine: Grammar of Graphics for Python
Awesome, basically a free book chapter. Will definitely fire up the notebook and give this a try.
adamchainz··on Problem solving with Unix commands
I learnt a lot from the book Data Science at the Command Line, now free and online at https://www.datascienceatthecommandline.com/