This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: SetType is missing in the 'types' module
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Kenji Asuka (Asuka Kenji), christian.heimes
Priority: normal Keywords:

Created on 2017-10-11 07:45 by Kenji Asuka (Asuka Kenji), last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg304112 - (view) Author: Kenji Asuka (Asuka Kenji) (Kenji Asuka (Asuka Kenji)) Date: 2017-10-11 07:45
# Create a dict and a set
d = {1: '1'}
s = {1}

# They have different types
print(type(d))             # <type 'dict'>
print(type(s))             # <type 'set'>
print(type(d) is type(s))  # False
print(type(s) is type(d))  # False
print(type(d) == type(s))  # False

# Dictionary type is found in 'types' module
print(type(d) is types.DictType)               # True
print(type(d) is types.DictionaryType)         # True
print(types.DictType == types.DictionaryType)  # True

# Set type is not found in 'types' module
print(type(s) is types.DictType)            # False
print(type(s) is types.DictionaryType)      # False
print(type(s) is types.DictProxyType)       # False
print(type(s) is types.ListType)            # False
print(type(s) is types.SliceType)           # False
print(type(s) is types.TupleType)           # False
print(type(s) is types.NotImplementedType)  # False
print(type(s) is types.SetType)             # AttributeError: 'module' object has no attribute 'SetType'
msg304113 - (view) Author: Kenji Asuka (Asuka Kenji) (Kenji Asuka (Asuka Kenji)) Date: 2017-10-11 07:52
'set' is a built-in type, and should belong to one of the types in the 'types' module. However, in the latest 2.7 implementations, none of the names matches the 'set' type.

Like 'list' and 'dict', I suppose there should be a name 'SetType' in the 'types' module. However, I guess it was forgotten to be created when the '{x: y}' syntax was introduced.
msg304114 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2017-10-11 08:02
The types modules is not suppose to hold all known types. It only contains types that are not available as builtin. The DictType member is a relict from the past. Before Python 2.2, the dict builtin and dict type were different things.

In Python 3, the types module no longer has DictType, IntType etc.
msg304116 - (view) Author: Kenji Asuka (Asuka Kenji) (Kenji Asuka (Asuka Kenji)) Date: 2017-10-11 08:23
You wrote:

> It only contains types that are not available as builtin.

I think the opposite is true.


As shown in the "Versions" field in the issue, this bug is Python 2 specific, so there is nothing to do with Python 3.

My point is not on 'dict', but on 'set'. So the history of 'dict' doesn't care.

As we can see there are names for:
- 'None' (types.NoneType)
- 'bool' (types.BooleanType)
- 'int' (types.IntType)
- 'long' (types.LongType)
- 'float' (types.FloatType)
- 'complex' (types.ComplexType)
- etc.

and more importantly:
- 'tuple' (types.TupleType)
- 'list' (types.ListType)
- 'dict' (types.DictType)

and since 'set' is also considered a built-in type (see https://docs.python.org/2/library/stdtypes.html), I can't see the reason WHY it is not considered a bug without having 'set' (types.SetType) in the module.
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75936
2017-10-11 08:23:22Kenji Asuka (Asuka Kenji)setmessages: + msg304116
2017-10-11 08:02:35christian.heimessetstatus: open -> closed

type: compile error -> behavior

nosy: + christian.heimes
messages: + msg304114
resolution: not a bug
stage: resolved
2017-10-11 07:52:44Kenji Asuka (Asuka Kenji)setmessages: + msg304113
2017-10-11 07:45:29Kenji Asuka (Asuka Kenji)create