Question: What I have at hand is a text file of decent size (~ 23MB). I am reading the file line by line and extracting a few words from each line based on some external criteria. For the sake of this example, let's say each line contains at least half a dozen tab-separated values and I am picking up all except the first and the last.

I want to output the set of *unique* words obtained this way, so obviously I want to store the extracted words in a `set`. Also, since `set.update(other)` is significantly faster than looping through `other` and adding one word at a time with `set.add(elem)`, I tried doing this:

```
all_words = set()
with open(my_tsv_file) as tsv_file:
    for line in tsv_file:
        wordlist = based_on_some_criteria(line)    # this is a list, not a set
        all_words.update(wordlist)

```

And this works fine. But when I replaced `all_words.update(wordlist)` with `all_words |= wordlist`, I got the following error:

```
TypeError: unsupported operand type(s) for |=: 'set' and 'list'

```

From the documentation, I understand that `update` and `|=` are equivalent. Further, since `|=` is supposed to accept any iterable, I also confirmed by doing this:

```
import collections
isinstance(wordlist, collections.Iterable)        # returns True

```

Why is the first approach using `set.update` working, but not the second one using `|=`?

Answer: 
> 
> From the documentation, I understand that update and |= are equivalent. Further, since |= is supposed to accept any iterable...
> 
> 
> 

From the documentation:

> 
> Note, the non-operator versions of the `update()`, `intersection_update()`, `difference_update()`, and `symmetric_difference_update()` methods will accept any iterable as an argument.
> 
> 
> 

The documentation does not seem to agree with your understanding.
`set` methods such as `update` accept arbitrary iterables, while `set` operators such as `|` and `|=` require sets.

Quoting [the documentation](https://docs.python.org/2/library/stdtypes.html#set-types-set-frozenset):

> 
> Note, the non-operator versions of `union()`, `intersection()`,
>  `difference()`, and `symmetric_difference()`, `issubset()`, and `issuperset()`
>  methods will accept any iterable as an argument. In contrast, their
>  operator based counterparts require their arguments to be sets. This
>  precludes error-prone constructions like `set('abc') & 'cbs'` in favor
>  of the more readable `set('abc').intersection('cbs')`.
> 
> 
>