[issue32025] Add time.thread_time()

2017-11-20 Thread STINNER Victor

STINNER Victor  added the comment:

I opened bpo-32093 for macOS. I close this one.

Nice enhancement, I already like this new clock ;-)

--
components: +FreeBSD -Library (Lib)
nosy: +koobs
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32025] Add time.thread_time()

2017-11-16 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Should I leave this open for you to work on the macOS implementation, Victor?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32025] Add time.thread_time()

2017-11-15 Thread Antoine Pitrou

Antoine Pitrou  added the comment:


New changeset 4bd41c9b52ea0c730e9e294caaf003e54c088c6e by Antoine Pitrou in 
branch 'master':
bpo-32025: Add time.thread_time() (#4410)
https://github.com/python/cpython/commit/4bd41c9b52ea0c730e9e294caaf003e54c088c6e


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32025] Add time.thread_time()

2017-11-15 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Le 15/11/2017 à 22:06, STINNER Victor a écrit :
> 
> I can work on the macOS implementation, once your PR will be merged.

Great!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32025] Add time.thread_time()

2017-11-15 Thread STINNER Victor

STINNER Victor  added the comment:

I can work on the macOS implementation, once your PR will be merged.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32025] Add time.thread_time()

2017-11-15 Thread Antoine Pitrou

Change by Antoine Pitrou :


--
keywords: +patch
pull_requests: +4359
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32025] Add time.thread_time()

2017-11-15 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Le 15/11/2017 à 02:48, STINNER Victor a écrit :
> 
> Would it be possible to not provide the function if it's not supported by a 
> platform?

Probably, yes.

> Do you know platforms which don't support time.thread_time()?

Any POSIX platform which doesn't have CLOCK_THREAD_CPUTIME_ID?  It's an
optional feature in the POSIX spec.

> Do you want to add time.thread_time_ns() with nanosecond resolution (PEP 564) 
> ?

Yes, I think so.

> It seems like macOS doesn't implement CLOCK_THREAD_CPUTIME_ID but
provides thread_info() which can be used by suming user and system times.

I don't have a macOS machine to test on, though :-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32025] Add time.thread_time()

2017-11-14 Thread STINNER Victor

STINNER Victor  added the comment:

It seems like macOS doesn't implement CLOCK_THREAD_CPUTIME_ID but provides 
thread_info() which can be used by suming user and system times.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32025] Add time.thread_time()

2017-11-14 Thread STINNER Victor

STINNER Victor  added the comment:

> On other platforms, it can simply raise NotImplementedError.

Would it be possible to not provide the function if it's not supported by a 
platform?

Do you know platforms which don't support time.thread_time()?

Do you want to add time.thread_time_ns() with nanosecond resolution (PEP 564) ? 
I suggest to add it to be consistent with time.process_time().

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32025] Add time.thread_time()

2017-11-14 Thread Antoine Pitrou

New submission from Antoine Pitrou :

Currently, the time module has time.process_time(), a cross-platform function 
for getting per-process elapsed CPU time.

Similarly, we could expose time.thread_time(), to get per-thread elapsed CPU 
time.
On a modern POSIX platform, it can use clock_gettime(CLOCK_THREAD_CPUTIME_ID).
On Windows, it can use GetThreadTimes(): 
https://msdn.microsoft.com/en-us/library/ms683237%28VS.85%29.aspx
On other platforms, it can simply raise NotImplementedError.

Currently, you would need ctypes hacks to call GetThreadTimes(), which is not 
very nice.

--
components: Library (Lib)
messages: 306210
nosy: belopolsky, haypo, pitrou
priority: normal
severity: normal
status: open
title: Add time.thread_time()
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com