Python: Split a comma-delimited string directly into a set
<p>I have some code that does something like:</p>

<pre><code>if string in comma_delimited_string.split(','):
    return True
</code></pre>

<p><a href="https://wiki.python.org/moin/PythonSpeed" rel="noreferrer">This website</a> says that membership testing with sets and dicts is much faster that with lists or tuples. I know doing <code>set(comma_delimited_string.split(','))</code> wouldn't improve speed because a list is still being created before it's converted into a set (or at least, it appeared to slow it down when I timed it). </p>

<p>I was wondering then, (mostly out of curiosity than real benefit to my code), is there a way to achieve the same effect of <code>comma_delimited_string.split(',')</code> but directly creating a set, instead of a list, with the intention of speeding up the above operation?</p>