Nothingness in Julia

Cameron April 3, 2024
Source
If you ever work in Julia, something you'll notice is that lots of people and the language server will recommend that you use or instead of the value comparison . This is also true of the functionality for missing values. Good discussion here, and a great Stack Overflow answer here. How meaningful is this, though? I decided to do some benchmarking to see how much of a difference this makes. The TLDR is that isn't specialized to checking , whereas and are. is a core language feature (I believe) and is compile time dispatched and is thus relatively quick. is a value comparison and I think requires some extra stuff to happen on top. There's a speed component to this too -- is the fastest on my machine, is the second fastest, and is the slowest. : : The bad one, : This is usually why the language server will recommend that you use or instead. Missing values The same is generally true of missing values. Missing values differ from in that they are used to represent missing data -- is returned by default when a return value is not otherwise specified. is more for cases where you don't know a value, e.g. if you don't have data for an observation in a statistical model. Interestingly, on Julia 1.10.2, the fastest is not one of the strict comparisons or , but a raw comparison using . Not really sure what's up with that, but whatever.

Discussion in the ATmosphere

Loading comments...