refactor duplicated code
optimise str/bytes.join() and infer the result type; improve type inference for called builtins
also optimise basestring.join() since we now infer this type in a couple of places
fix return type of repr(): CPython guarantees to return str