Is `beartype.door` still O(1)?
See original GitHub issueThis commit is extremely exciting. I really like the typechecking ideas in awfutils
, and this is something I’ve been hoping to see in @beartype for a long time. However, I worry about the overhead involved in inserting tons of assert()
calls within the bodies of potentially every function in a codebase. I sometimes write code where almost half the statements in a function are annotated with an inline hint. In a 7-figure line count codebase, won’t we run into significant performance overhead, even if the typechecking itself is O(1) in the data?
Can anyone think of any easy way to benchmark this?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Unbearably fast near-real-time runtime type-checking ... - GitHub
Unlike static type checkers, beartype can't be opinionated about things that no one should be. If none of the above still apply, still...
Read more >GitHub - beartype/beartype: Unbearably fast O(1) runtime type ...
A runtime type checker that uses random sampling of the data being checked. It's very sussy.
Read more >Customer reviews: BETTERCLOUD Large Locking Cat Jaw ...
1990 Jeep Wrangler 1/2 doors made of scrap I had laying around and the BETTERCLOUD Large Locking Cat Jaw Claw Door Latches w/Installation...
Read more >Ewok - StarWars.com
The Ewoks are sentient furred bipeds native to the moon of Endor. They are curious individuals that stand about one meter tall. They...
Read more >2023 Best Colleges with No Application Fee in America - Niche
For a school in one of the most diverse cities in the country, ... It's easy to navigate and get around, but there's...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, you’ve got me there! Sounds like it’s a non-issue, despite being
O(k)
in the number of annotations. As for the import hooks. Well, all I have to say is that when you’re taking an extreme measure (and I think doing all of this is an extreme measure), it seems polite to make the toggles opt-in instead of opt-out. I suppose the whole thing is of course opt-in. One of the things I like about the existing decorator is that it is very explicit. Import hooks scare me because I think I might forget that I’m using them, and leave them on when for some reason or another they shouldn’t be.Anyhow, I think the concern has been addressed. Feel free to close!
Right? Import hooks fundamentally violate Python’s “Explicit is better than implicit!” maxim, which is perhaps not so good. My cynical suspicion, however, is that most users simply don’t care about purist ideology the way we do. As typing zealots, we’re mostly fine with all of the manual legwork that @beartype currently mandates. This is a useful tradeoff for people like us, because we retain full and total control over runtime type-checking over all time and space. In return, all @beartype demands is our scarce minutes, precious lifeblood, and eternal souls.
But most users aren’t like us. Most users don’t have the resources or inclination to manually manage boilerplate churn like that. Decorating every class and callable across a million-line codebase with
@beartype.beartype
is a hard blocker – and I feel that real-world pain. It’s understandable.Import hooks fill that adoption gap by eliminating the current prohibitive cost of @beartype’s buy-in. Gah! Tech jargon, thy name is this thread.
Thanks so much for all the ongoing excitement, @langfield. If you’d like to see whitelisting or blacklisting features like the above
@beartype_no_pep526
, it’d be great if you could open up a new issue. Remind us all of my hollow promises to do something. 😄