ENH: Update default timing precision to 4 digits and add global precision control for Timer and timeit #805
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.
This PR enhances QuantEcon's timing functionality by updating the default precision and adding global precision control capabilities for modern timing functions.
Changes Made
1. Updated Default Precision
Timer class and timeit function now default to 4 decimal places instead of 2:
2. Added Global Precision Control
Introduced
qe.timings.float_precision()function to set precision globally for Timer and timeit:3. Affected Functions
The following functions now use the global precision by default:
Timerclass context managertimeit()functionThe following deprecated functions maintain their original behavior:
tic(),tac(),toc()functions (continue using digits=2 default)loop_timer()function (continues using digits=2 default)4. Backward Compatibility
Explicit precision parameters still work and override the global setting:
Implementation Details
quantecon.timingsmodule with precision managementTesting
All 27 timing tests pass, covering:
Fixes #804.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.