[Python-Dev] Remove own implementation for thread-local storage

2017-07-03 Thread Masayuki YAMAMOTO
Hi, python-dev.

I'd propose removing code which I think out-of-date.
CPython has provided the own implementation for thread-local storage (TLS)
on Python/thread.c, it's used in the case which a platform has not supplied
native TLS.  However, currently all supported platforms (NT and pthreads)
have provided native TLS and defined the Py_HAVE_NATIVE_TLS macro with
unconditional in any case.
If the code is removed, the new TLS API for PEP 539 won't have to care the
reinitialization of the thread keys managed by the interpreter (i.e.
PyThread_ReInitTLS function has been working for own implementation and
will be no longer necessary for new API).  Does anyone have a reason we
should keep it?

Regards,
Masayuki
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] 64 bit units in PyLong

2017-07-03 Thread Victor Stinner
2017-07-03 6:52 GMT+02:00 Siyuan Ren :
> The current PyLong implementation represents arbitrary precision integers in
> units of 15 or 30 bits. I presume the purpose is to avoid overflow in
> addition , subtraction and multiplication. But compilers these days offer
> intrinsics that allow one to access the overflow flag, and to obtain the
> result of 64 bit multiplication as a 128 bit number.

The question is the performance. Is it fast? :-)

You can try to write a patch and run a benchmark.

See for example http://pyperformance.readthedocs.io/ for benchmarks.

Victor
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Remove own implementation for thread-local storage

2017-07-03 Thread Victor Stinner
I'm in favor of removing it. I know that it confused people many
times, they look at this fallback and found an issue, whereas I'm not
aware of any platform using this fallback anymore.

Can you please write a PR just to remove this fallback? We can merge
it and then check buildbots :-) So in the worst case, we can revert
it.

Victor

2017-07-03 9:32 GMT+02:00 Masayuki YAMAMOTO :
> Hi, python-dev.
>
> I'd propose removing code which I think out-of-date.
> CPython has provided the own implementation for thread-local storage (TLS)
> on Python/thread.c, it's used in the case which a platform has not supplied
> native TLS.  However, currently all supported platforms (NT and pthreads)
> have provided native TLS and defined the Py_HAVE_NATIVE_TLS macro with
> unconditional in any case.
> If the code is removed, the new TLS API for PEP 539 won't have to care the
> reinitialization of the thread keys managed by the interpreter (i.e.
> PyThread_ReInitTLS function has been working for own implementation and will
> be no longer necessary for new API).  Does anyone have a reason we should
> keep it?
>
> Regards,
> Masayuki
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com
>
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Remove own implementation for thread-local storage

2017-07-03 Thread Antoine Pitrou

Also note that C11, MSVC and some Unix C compilers have built-in support
for thread-local variables.  Example:
https://github.com/numba/numba/blob/master/numba/_random.c#L114-L119

Regards

Antoine.


On Mon, 3 Jul 2017 10:07:06 +0200
Victor Stinner  wrote:

> I'm in favor of removing it. I know that it confused people many
> times, they look at this fallback and found an issue, whereas I'm not
> aware of any platform using this fallback anymore.
> 
> Can you please write a PR just to remove this fallback? We can merge
> it and then check buildbots :-) So in the worst case, we can revert
> it.
> 
> Victor
> 
> 2017-07-03 9:32 GMT+02:00 Masayuki YAMAMOTO :
> > Hi, python-dev.
> >
> > I'd propose removing code which I think out-of-date.
> > CPython has provided the own implementation for thread-local storage (TLS)
> > on Python/thread.c, it's used in the case which a platform has not supplied
> > native TLS.  However, currently all supported platforms (NT and pthreads)
> > have provided native TLS and defined the Py_HAVE_NATIVE_TLS macro with
> > unconditional in any case.
> > If the code is removed, the new TLS API for PEP 539 won't have to care the
> > reinitialization of the thread keys managed by the interpreter (i.e.
> > PyThread_ReInitTLS function has been working for own implementation and will
> > be no longer necessary for new API).  Does anyone have a reason we should
> > keep it?
> >
> > Regards,
> > Masayuki
> >
> > ___
> > Python-Dev mailing list
> > Python-Dev@python.org
> > https://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe:
> > https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com
> >  



___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Remove own implementation for thread-local storage

2017-07-03 Thread Victor Stinner
Sadly, we only require C99 yet :-/

Victor

2017-07-03 10:19 GMT+02:00 Antoine Pitrou :
>
> Also note that C11, MSVC and some Unix C compilers have built-in support
> for thread-local variables.  Example:
> https://github.com/numba/numba/blob/master/numba/_random.c#L114-L119
>
> Regards
>
> Antoine.
>
>
> On Mon, 3 Jul 2017 10:07:06 +0200
> Victor Stinner  wrote:
>
>> I'm in favor of removing it. I know that it confused people many
>> times, they look at this fallback and found an issue, whereas I'm not
>> aware of any platform using this fallback anymore.
>>
>> Can you please write a PR just to remove this fallback? We can merge
>> it and then check buildbots :-) So in the worst case, we can revert
>> it.
>>
>> Victor
>>
>> 2017-07-03 9:32 GMT+02:00 Masayuki YAMAMOTO :
>> > Hi, python-dev.
>> >
>> > I'd propose removing code which I think out-of-date.
>> > CPython has provided the own implementation for thread-local storage (TLS)
>> > on Python/thread.c, it's used in the case which a platform has not supplied
>> > native TLS.  However, currently all supported platforms (NT and pthreads)
>> > have provided native TLS and defined the Py_HAVE_NATIVE_TLS macro with
>> > unconditional in any case.
>> > If the code is removed, the new TLS API for PEP 539 won't have to care the
>> > reinitialization of the thread keys managed by the interpreter (i.e.
>> > PyThread_ReInitTLS function has been working for own implementation and 
>> > will
>> > be no longer necessary for new API).  Does anyone have a reason we should
>> > keep it?
>> >
>> > Regards,
>> > Masayuki
>> >
>> > ___
>> > Python-Dev mailing list
>> > Python-Dev@python.org
>> > https://mail.python.org/mailman/listinfo/python-dev
>> > Unsubscribe:
>> > https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com
>> >
>
>
>
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> https://mail.python.org/mailman/options/python-dev/victor.stinner%40gmail.com
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Need help to review a test_nntplib enhancement:

2017-07-03 Thread Victor Stinner
Hi,

Sometimes, for an unknown reason, test_nntplib fails randomly:

  http://bugs.python.org/issue19613

Martin Panter wrote a patch, but since I don't know how to reproduce
the bug, I'm unable to test it. Moreover, I don't know nntplib nor
test_nntplib, so I don't feel able to review it.

Sadly, Martin doesn't feel confident enough in his patch neither,
since again, he is unable to test it.

As a result, the issue is stuck and the bug continues to occur
sometimes on buildbots.

Victor
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Remove own implementation for thread-local storage

2017-07-03 Thread Nick Coghlan
On 3 July 2017 at 20:02, Victor Stinner  wrote:
> Sadly, we only require C99 yet :-/

Handling fallbacks when shiny new features are unavailable is what
autoconf is for, though :)

The fact thread specific storage support made it directly into C11
makes me more confident in dropping our emulation, so +1 for
investigating that *before* we finalize PEP 539.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Remove own implementation for thread-local storage

2017-07-03 Thread Victor Stinner
>> I'd propose removing code which I think out-of-date.

Already done!
https://github.com/python/cpython/commit/aa0aa0492c5fffe750a26d2ab13737a1a6d7d63c
(and no buildbot complained).

Victor
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com