Make tuple checks faster (#16657)
Summary:
As the comment indicates, the issue is only present in some versions of
Python 2, so we should be able to use heavily optimized PyTuple_Check in
most cases, and skip allocation of the strings, and unnecessary lookups
on object's type.
cc ezyang zasdfgbnm
Pull Request resolved: https://github.com/pytorch/pytorch/pull/16657
Differential Revision: D13957854
Pulled By: ezyang
fbshipit-source-id: be32eb473ad77a0805e8247d8d583d673d4bdf25