Add if-unlikely construct?

9 views
Skip to first unread message

Taras Kozlov

unread,
May 6, 2026, 9:55:33 AM (2 days ago) May 6
to cython-users
Hi all,
Maybe this has been already discussed or implemented in some way, but I couldn't find anything.

In my code, I would like to mark certain if branches as unlikely
```cython
if (cython.unlikely(some_condition)):
    # do something
```

I noticed that cython already adds `unlikely` for the branches that raise exceptions. Maybe it wouldn't be to difficult to expose a generic mechanism for user.

I'm happy to try and do it myself, just want get an opinion first how, regarding syntax. Does approach with `cython.unlikely` look good? Are there any caveats?

Thank you
Reply all
Reply to author
Forward
0 new messages