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

2017-07-05 Thread INADA Naoki
> > Would there be any benefit in making a C implementation available from > Python? > > -CHB > Yes, at startup time point of view. Current Python namedtuple implementation uses `eval`. It means we can't cache bytecode in pyc files. For example, importing functools is not so fast and its because

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

2017-07-05 Thread Chris Barker
On Mon, Jun 19, 2017 at 8:04 PM, Nick Coghlan wrote: > As context for anyone not familiar with the time module precedent that > Guido mentioned, we have a C level `PyStructSequence` that provides > some of the most essential namedtuple features, but not all of them: > https://github.com/python/cp

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

2017-06-22 Thread Thomas Güttler
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

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

2017-06-20 Thread Victor Stinner
2017-06-20 4:05 GMT+02:00 INADA Naoki : > Namedtuple in Python make startup time slow. > So I'm very conservative to convert tuple to namedtuple in Python. > INADA Naoki While we are talking about startup time, I would be curious of seeing the overhead (python startup time, when importing socket

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

2017-06-19 Thread Nick Coghlan
On 20 June 2017 at 12:05, INADA Naoki wrote: > Namedtuple in Python make startup time slow. > So I'm very conservative to convert tuple to namedtuple in Python. Aye, I don't think a Python level wrapper would be the right way to go here - while namedtuple is designed to be as cheap as normal tupl

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

2017-06-19 Thread INADA Naoki
Namedtuple in Python make startup time slow. So I'm very conservative to convert tuple to namedtuple in Python. INADA Naoki On Tue, Jun 20, 2017 at 7:27 AM, Victor Stinner wrote: > Oh, about the cost of writing C code, we started to enhance the socket > module in socket.py but keep the C code

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

2017-06-19 Thread Victor Stinner
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" a écrit : > There are examples in timemodu

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

2017-06-19 Thread Guido van Rossum
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 op

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

2017-06-19 Thread Victor Stinner
Hi, 2017-06-13 22:13 GMT+02:00 Thomas Güttler : > 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"

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

2017-06-19 Thread George Fischhof
+1 ;-) for example to get IP address of all interfaces we have to use the third (indexed as 2) member of "something" it is much more beatiful to get ip_address: *import *socket *for *ip *in *socket.gethostbyname_ex(socket.gethostname())[2]: print(ip) BR, George 2017-06-13 22:13 GMT+02:00 T

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

2017-06-13 Thread Thomas Güttler
AFAIK the socket module returns plain tuples in Python3: https://docs.python.org/3/library/socket.html Why not use named tuples? Regards, Thomas Güttler -- I am looking for feedback for my personal programming guidelines: https://github.com/guettli/programming-guidelines __