Skip to content

Latest commit

 

History

History
88 lines (58 loc) · 1.68 KB

README.rst

File metadata and controls

88 lines (58 loc) · 1.68 KB
PEP: 9999
Title: Measurement Abbreviations in Numeric Literals
Author: Artyom Gavrichenkov <[email protected]>,
Dmitry Nazarov <[email protected]>
Status: Draft
Type: Standards Track
Content-Type: text/x-rst
Created: 22-Jul-2018
Python-Version: 3.8
Post-History: 30-Aug-2002

Abstract

TODO

Rationale

TODO

Syntax and semantics

Instead of writing this:

MINUTES = 60
timeout = 20 * MINUTES

or this:

timeout = 20 * 60  # 20 minutes

we will write this:

>>> timeout = 20 min
>>> print(timeout)
1200

This will also work nicely in terms of different units:

>>> timeout = 5 h + 20 min
>>> print(timeout)
19200

More examples:

connect(buffer = 4K, ..)  #  4096
sleep(1 min)              #    60
TOKEN_TTL = 8h            # 28800
MAX_WEIGHT = 7.5 kg       #  7500
TODO: more real world examples
TODO: how this will work within string formatting

References

[1]Proof of concept implementation (https://github.com/nazarov-tech/cpython/tree/measurement-abbreviations)

Copyright

Copyright (c) 2018 by Artyom Gavrichenkov <[email protected]>,
Dmitry Nazarov <[email protected]>.
This material may be distributed only subject to the terms and conditions
set forth in the Open Publication License, v1.0 or later
(the latest version is presently available