def partition(self, key, partitions):
        """
        Select a partition based on the hash of the key.

        :param key: Partition key
        :type key: text string or UTF-8 `bytes` or `bytearray`
        :param list partitions:
            An indexed sequence of partition identifiers.
        :returns:
            One of the given partition identifiers. The result will be the same
            each time the same key and partition list is passed.
        """
        return partitions[(self._hash(key) & 0x7FFFFFFF) % len(partitions)]
Select a partition based on the hash of the key.

        :param key: Partition key
        :type key: text string or UTF-8 `bytes` or `bytearray`
        :param list partitions:
            An indexed sequence of partition identifiers.
        :returns:
            One of the given partition identifiers. The result will be the same
            each time the same key and partition list is passed.