[Python-ideas] socket module: plain stuples vs named tuples - Thank you

Thomas Güttler guettliml at thomas-guettler.de
Thu Jun 22 11:25:26 EDT 2017


thank you! I am happy that Guido is open for  a pull request ... There were +1 votes, too (and some concern about python 
startup time).


I stopped coding in spare time, since my children are more important at the moment .. if some wants to try it ... go 
ahead and implement named tuples for the socket standard library - would be great.

Just for the records, I came here because of this feature request:

    https://github.com/giampaolo/psutil/issues/928

Regards,
   Thomas Güttler

PS: For some strange reasons I received only some mails of this thread. But I could
find the whole thread in the archive.

Am 20.06.2017 um 04:05 schrieb INADA Naoki:
> Namedtuple in Python make startup time slow.
> So I'm very conservative to convert tuple to namedtuple in Python.
> INADA Naoki  <songofacandy at gmail.com>
> 
> 
> On Tue, Jun 20, 2017 at 7:27 AM, Victor Stinner
> <victor.stinner at gmail.com> wrote:
>> Oh, about the cost of writing C code, we started to enhance the socket
>> module in socket.py but keep the C code unchanged. I am thinking to the
>> support of enums. Some C functions are wrapped in Python.
>>
>> Victor
>>
>> Le 19 juin 2017 11:59 PM, "Guido van Rossum" <guido at python.org> a écrit :
>>>
>>> There are examples in timemodule.c which went through a similar conversion
>>> from plain tuples to (sort-of) named tuples. I agree that upgrading the
>>> tuples returned by the socket module to named tuples would be nice, but it's
>>> a low priority project. Maybe someone interested can create a PR? (First
>>> open an issue stating that you're interested; point to this email from me to
>>> prevent that some other core dev just closes it again.)
>>>
>>> On Mon, Jun 19, 2017 at 2:24 PM, Victor Stinner <victor.stinner at gmail.com>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> 2017-06-13 22:13 GMT+02:00 Thomas Güttler <guettliml at thomas-guettler.de>:
>>>>> AFAIK the socket module returns plain tuples in Python3:
>>>>>
>>>>>    https://docs.python.org/3/library/socket.html
>>>>>
>>>>> Why not use named tuples?
>>>>
>>>> For technical reasons: the socket module is mostly implemented in the
>>>> C language, and define a "named tuple" in C requires to implement a
>>>> "sequence" time which requires much more code than creating a tuple.
>>>>
>>>> In short, create a tuple is as simple as Py_BuildValue("OO", item1,
>>>> item2).
>>>>
>>>> Creating a "sequence" type requires something like 50 lines of code,
>>>> maybe more, I don't know exactly.
>>>>
>>>> Victor
>>>> _______________________________________________
>>>> Python-ideas mailing list
>>>> Python-ideas at python.org
>>>> https://mail.python.org/mailman/listinfo/python-ideas
>>>> Code of Conduct: http://python.org/psf/codeofconduct/
>>>
>>>
>>>
>>>
>>> --
>>> --Guido van Rossum (python.org/~guido)
>>
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
> 

-- 
Thomas Guettler http://www.thomas-guettler.de/


More information about the Python-ideas mailing list