You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These *Types has a long history. You can find them since the first commit of pygame on github.
They are aliases of the original type object and are not recommended to use.
What are *Type used for?
Before python 2.3, there is no tp_new slot in PyTypeObject struct. People use a function to "new" a class defined by c extension.
// Copied from https://docs.python.org/2.2/ext/dnt-basics.html
...
staticPyMethodDefnoddy_methods[] = {
{"new_noddy", noddy_new_noddy, METH_VARARGS,
"Create a new Noddy object."},
{NULL, NULL, 0, NULL}
};
DL_EXPORT(void)
initnoddy(void)
{
noddy_NoddyType.ob_type=&PyType_Type;
Py_InitModule("noddy", noddy_methods);
}
Take Event as an example, at that time, EventType is the type of event, people need to call Event() function, to create an EventType object.
After python2.3, API changed, people no longger need a explicit function to "new" a class
// Copied from https://docs.python.org/2.3/ext/dnt-basics.html
...
staticPyMethodDefnoddy_methods[] = {
{NULL} /* Sentinel */
};
#ifndefPyMODINIT_FUNC/* declarations for DLL import/export */#definePyMODINIT_FUNC void
#endifPyMODINIT_FUNCinitnoddy(void)
{
PyObject*m;
noddy_NoddyType.tp_new=PyType_GenericNew;
if (PyType_Ready(&noddy_NoddyType) <0)
return;
m=Py_InitModule3("noddy", noddy_methods,
"Example module that creates an extension type.");
Py_INCREF(&noddy_NoddyType);
PyModule_AddObject(m, "Noddy", (PyObject*)&noddy_NoddyType);
}
Again, take Event as example, now people only need to call EventType() to create an EventType object
To keep the compatibility of the code written before python 2.2, the Event become the type name and EventType become an alias.
People can still call Event() to get an Event object.
These could explain why there are so many *Type in pygame.
Deprecate and remove
These aliases are created to keep the compatibility with python 2.2, whose last release is on 30 May 2003.
Today is 25 Nov 2024, we are currently dropping python 3.8 and porting modules to SDL3.
So, why not?
The text was updated successfully, but these errors were encountered:
I consider these deprecated already, they're not documented or anything. Are you proposing to add deprecation warnings on their use? If so, how? They are not as straightforward to add a warning to as a function.
CameraType
EventType
FontType
JoystickType
MaskType
SoundType
ChannelType
RectType
FRectType
(what?)SurfaceType
These
*Type
s has a long history. You can find them since the first commit of pygame on github.They are aliases of the original type object and are not recommended to use.
What are
*Type
used for?Before python 2.3, there is no
tp_new
slot inPyTypeObject
struct. People use a function to "new" a class defined by c extension.Take
Event
as an example, at that time,EventType
is the type of event, people need to callEvent()
function, to create anEventType
object.After python2.3, API changed, people no longger need a explicit function to "new" a class
Again, take
Event
as example, now people only need to callEventType()
to create anEventType
objectTo keep the compatibility of the code written before python 2.2, the
Event
become the type name andEventType
become an alias.People can still call
Event()
to get anEvent
object.These could explain why there are so many
*Type
in pygame.Deprecate and remove
These aliases are created to keep the compatibility with python 2.2, whose last release is on 30 May 2003.
Today is 25 Nov 2024, we are currently dropping python 3.8 and porting modules to SDL3.
So, why not?
The text was updated successfully, but these errors were encountered: