Improve comparison performance (closes #1)

Thanks to @sgruhier