# X === nothing vs x isa Nothing

**URL:** <https://discourse.julialang.org/t/x-nothing-vs-x-isa-nothing/64546>\
**Category:** General Usage\
**Created:** [July 13, 2021, 12:53am UTC](https://discourse.julialang.org/t/x-nothing-vs-x-isa-nothing/64546 "2021-07-13T00:53:54Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![ess3sq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ess3sq/32/26834_2.png) [@ess3sq](https://discourse.julialang.org/u/ess3sq)\
**Post date:** [July 13, 2021, 1:22pm UTC](https://discourse.julialang.org/t/x-nothing-vs-x-isa-nothing/64546/12 "2021-07-13T13:22:17Z")

</div>

It is perhaps (just about) slightly interesting to look at the performance.

Among `x === nothing`, `x isa Nothing` and `isnothing(x)`, `===` seems to be the fastest and `isnothing()` the slowest ([timing](https://replit.com/@ess3sq/timenothing)).

This makes sense because checking for identity (`===` pointer comparison) is quicker than checking a type, for the type has to be looked up in an internal table which causes a slight overhead. the function call is slower still for clear reasons.

This “analysis” is not worth much though, because firstly `isnothing()` is slightly different than the other two as it can be extended, while the other two are close enough that in a real program this would not make any difference. As such, I guess performance comparisons on this are little more than academic interest.

// Edit  
if the object being compared is actually `nothing`, then `isnothing()` is much faster and about the same time of `isa Nothing`. Is `isnothing(x::Nothing)` perhaps inlined to just return `true`? It woud make sense and explains why it is just the same time as a type check.

---

_[View the full topic](https://discourse.julialang.org/t/x-nothing-vs-x-isa-nothing/64546)._
