Skip to content

compat: use timeit.default_timer instead of time.clock which is gone in Python 3.8#302

Closed
lazka wants to merge 1 commit intosqlalchemy:masterfrom
lazka:dont-use-time-clock
Closed

compat: use timeit.default_timer instead of time.clock which is gone in Python 3.8#302
lazka wants to merge 1 commit intosqlalchemy:masterfrom
lazka:dont-use-time-clock

Conversation

@lazka
Copy link
Copy Markdown
Contributor

@lazka lazka commented Jul 24, 2019

Python 3.8 has dropped the deprecated time.clock() function which makes mako fail
with an AttributeError on import on Windows.

The way time_func was defined (clock() on Windows and time() everywhere else) made it
return a high precision wall clock time without a defined reference. This is exactly
what timeit.default_timer() does for all versions of Python on all platforms,
so just use that instead.

Fixes #301

…in Python 3.8

Python 3.8 has dropped the deprecated time.clock() function which makes mako fail
with an AttributeError on import on Windows.

The way time_func was defined (clock() on Windows and time() everywhere else) made it
return a high precision wall clock time without a defined reference. This is exactly
what timeit.default_timer() does for all versions of Python on all platforms,
so just use that instead.

Fixes sqlalchemy#301
Comment thread mako/compat.py
@zzzeek zzzeek requested a review from sqla-tester July 26, 2019 02:17
Copy link
Copy Markdown
Collaborator

@sqla-tester sqla-tester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this is sqla-tester setting up my work to try to get revision a706e95 of this pull request into gerrit so we can run tests and reviews and stuff

@sqla-tester
Copy link
Copy Markdown
Collaborator

New Gerrit review created for change a706e95: https://gerrit.sqlalchemy.org/#/c/sqlalchemy/mako/+/1377

@sqla-tester
Copy link
Copy Markdown
Collaborator

mike bayer (zzzeek) wrote:

Code-Review+2 Workflow+1

@sqla-tester
Copy link
Copy Markdown
Collaborator

Gerrit review https://gerrit.sqlalchemy.org/1377 has been merged. Congratulations! :)

@zzzeek
Copy link
Copy Markdown
Member

zzzeek commented Jul 27, 2019

thanks!

artdogma added a commit to artdogma/pymako that referenced this pull request Aug 27, 2025
Replaced usage of time.clock() on windows as well as time.time() elsewhere
for microsecond timestamps with timeit.default_timer(), as time.clock() is
being removed in Python 3.8.   Pull request courtesy Christoph Reiter.

Fixes: #301

Closes: #302
Pull-request: sqlalchemy/mako#302
Pull-request-sha: a706e952727337702692fd1d8369d259e1600d6e

Change-Id: I24e2cd3d2c02323a6fa2b063e86cabe555df2036
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uses time.clock() on Windows which is gone with Python 3.8

4 participants