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
Closed
compat: use timeit.default_timer instead of time.clock which is gone in Python 3.8#302lazka wants to merge 1 commit intosqlalchemy:masterfrom
lazka wants to merge 1 commit intosqlalchemy:masterfrom
Conversation
…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
This was referenced Jul 24, 2019
zzzeek
reviewed
Jul 24, 2019
sqla-tester
reviewed
Jul 26, 2019
Collaborator
sqla-tester
left a comment
There was a problem hiding this comment.
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
Collaborator
|
New Gerrit review created for change a706e95: https://gerrit.sqlalchemy.org/#/c/sqlalchemy/mako/+/1377 |
Collaborator
|
mike bayer (zzzeek) wrote: Code-Review+2 Workflow+1 |
Collaborator
|
Gerrit review https://gerrit.sqlalchemy.org/1377 has been merged. Congratulations! :) |
Member
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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