[Python-checkins] peps: Removed Implementation Limitations section. While the version of the code on

eric.smith python-checkins at python.org
Fri Sep 4 21:01:22 CEST 2015


https://hg.python.org/peps/rev/a0194ec4195c
changeset:   6029:a0194ec4195c
user:        Eric V. Smith <eric at trueblade.com>
date:        Fri Sep 04 15:01:35 2015 -0400
summary:
  Removed Implementation Limitations section. While the version of the code on http://bugs.python.org/issue24965 has the 255 expression limitation, I'm going to remove this limit. The i18n section was purely speculative. We can worry about it if/when we add i18n and i-strings.

files:
  pep-0498.txt |  55 ----------------------------------------
  1 files changed, 0 insertions(+), 55 deletions(-)


diff --git a/pep-0498.txt b/pep-0498.txt
--- a/pep-0498.txt
+++ b/pep-0498.txt
@@ -634,61 +634,6 @@
   print("Usage: {0} [{1}]".format(sys.argv[0], '|'.join('--'+opt for opt in valid_opts)), file=sys.stderr)
   print(f"Usage: {sys.argv[0]} [{'|'.join('--'+opt for opt in valid_opts)}]", file=sys.stderr)
 
-Implementation limitations
-==========================
-
-Maximum of 255 expressions
---------------------------
-
-Due to a CPython limit with the number of parameters to a function, an
-f-string may not contain more that 255 expressions. This includes
-expressions inside format specifiers. So this code would count as
-having 2 expressions::
-
-  f'{x:.{width}}'
-
-The same expression used multiple times
----------------------------------------
-
-Every expression in an f-string is evaluated exactly once for each
-time it appears in the f-string. However, when the same expression
-appears more than once in an f-string, it's undefined which result
-will be used in the resulting string value. This only matters for
-expressions with side effects.
-
-For purposes of this section, two expressions are the same if they
-have the exact same literal text defining them. For example, ``'{i}'``
-and ``'{i}'`` are the same expression, but ``'{i}'`` and ``'{i }'``
-are not, due to the extra space in the second expression.
-
-For example, given::
-
-  >>> def fn(lst):
-  ...    lst[0] += 1
-  ...    return lst[0]
-  ...
-  >>> lst=[0]
-  >>> f'{fn(lst)} {fn(lst)}'
-  '1 2'
-
-The resulting f-string might have the value ``'1 2'``, ``'2 2'``,
-``'1 1'``, or even ``'2 1'``.
-
-However::
-
-  >>> lst=[0]
-  >>> f'{fn(lst)} { fn(lst)}'
-  '1 2'
-
-This f-string will always have the value ``'1 2'``. This is due to the
-two expressions not being the same: the space in the second example
-makes the two expressions distinct.
-
-This restriction is in place in order to allow for a possible future
-extension allowing translated strings, wherein the expression
-substitutions would be identified by their text representations in the
-f-strings.
-
 References
 ==========
 

-- 
Repository URL: https://hg.python.org/peps


More information about the Python-checkins mailing list