Fuse steps in `extract_serialize` (#4254)
Fuse steps in `extract_serialize` (#4254)

* Join `list` & `dict` code in `_extract_serialize`

* Flip order of `dict` and `list` check

This matches the ordering we have elsewhere.

* Call `type(x)` once

* Assign `path + (k,)` in `_extract_serialize`

To avoid having to reconstruct this value in every case, simply assign
`path_k` with the result of `path + (k,)`.

* Rename `typ` to `typ_v` for clarity

* Use `is` and `or` instead of `in`

This is a bit faster than using `in`, which needs to constructing a
`tuple` and then check for a type match. Also matches what the other
conditions do.

* Avoid unneeded copying of message to serialize

* Collect `bytestrings` when recursing too
dask/distributed,dask/distributed,dask/distributed,dask/distributed