help you fix your problem Python's in operator calls the __contains__ magic function on the container. That is implemented in different ways for different containers. For strings, lists and tuples, it's a linear search (O(N)), though since it's implemented in C it will probably be faster than the pure-python one you have in your question.
How do I perform a linear search over this inventory array then the index of the matching item if it is found, -1 if it
With these it helps The easiest way I've found to handle this and case-insensitive unique indexes with PG/Sails is to use the citext column type instead of text/character varying types (compared to forcing everything to lowercase which stinks). citext is a case insensitive text datatype. "Essentially, it internally calls lower when comparing values. Otherwise, it behaves almost exactly like text."