Hacker Newsnew | past | comments | ask | show | jobs | submit | adamchainz's commentslogin

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.


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

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!


OP here, thanks for the praise!

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


You are a great writer - thanks for putting this together!


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-...


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


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"


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


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


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


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: