From the documentation (emphasis mine):
Cast a value to a type.
This returns the value unchanged. To the type checker this signals that the return value has the designated type, but at runtime we intentionally don’t check anything (we want this to be as fast as possible).
The “casting” only takes place in the type-checking system, not at runtime.
Related Contents:
- Change column type in pandas
- Fastest way to convert a dict’s keys & values from `unicode` to `str`?
- Determine the type of an object?
- How to determine a Python variable’s type?
- How do I check if a string is a number (float)?
- What’s the canonical way to check for type in Python?
- What are the differences between type() and isinstance()?
- How to check if type of a variable is string?
- List vs tuple, when to use each? [duplicate]
- How to find out if a Python object is a string?
- How to check if an object is a list or tuple (but not string)?
- In Python, how do I convert all of the items in a list to floats?
- Test if a variable is a list or tuple
- Can pandas automatically read dates from a CSV file?
- How to compare type of an object in Python?
- How do I check if a string represents a number (float or int)?
- How do I find numeric columns in Pandas?
- How does Python 2 compare string and int? Why do lists compare as greater than numbers, and tuples greater than lists?
- How to check if string input is a number?
- What is dtype(‘O’), in pandas?
- Python check if variable isinstance of any type in list
- How to know function return type and argument types?
- Strings in a DataFrame, but dtype is object
- What is the most pythonic way to check if an object is a number?
- Import pandas dataframe column as string not int
- How to determine if a number is any type of int (core or numpy, signed or not)?
- Check if all elements of a list are of the same type
- How to keep leading zeros in a column when reading CSV with Pandas?
- Copying a column from one DataFrame to another gives NaN values?
- Append a tuple to a list – what’s the difference between two ways?
- Pandas reading csv as string type
- How can I check if string input is a number?
- Why are single type constraints disallowed in Python?
- Store different datatypes in one NumPy array?
- How to set the python type hinting for a dictionary variable?
- How to get the range of valid Numpy data types?
- Python JSON encoding
- Python sum, why not strings? [closed]
- Check if a parameter is a Python module?
- Efficient way to convert strings from split function to ints in Python
- How do I convert all of the items in a list to floats? [duplicate]
- Do union types actually exist in python?
- Where are python bytearrays used?
- Type hinting in Python 2
- When to apply(pd.to_numeric) and when to astype(np.float64) in python?
- The real difference between float32 and float64
- How do you set a conditional in python based on datatypes?
- How can I copy an immutable object like tuple in Python?
- What are the main differences of NamedTuple and TypedDict in Python / mypy
- How to type hint a generic numeric type in Python?