Re:Building a full-text search engine in 150 lines of Python...
by hacked_greenhat on Friday January 24, 2025 @10:36AM
(#42814107)
https://stackoverflow.com/questions/8748036/is-there-a-built...
While this doesn't explain why filter accepts None as the lambda, I think the fact that there are no builtin identity function kind of explains why. It's easier to write None rather than put an identity lambda. I reckon it also makes it easier for a compiler to optimize this specific case.
Re:Building a full-text search engine in 150 lines of Python...
by evnp on Sunday January 26, 2025 @10:34AM
(#42830709)
Thanks for the explanation. I take your point, but in the `filter` case `bool` seems just as easy as `None`, but with the added benefit that no awareness of a special case is needed -- any python programmer should understand how the `bool` builtin works. Curious if there's any downside.
If not, I'm now curious why the `None` special case was added to `filter`..