Formatted string literals are a new kind of string literal, prefixed with 'f'. They are similar to the format strings accepted by str.format(). They contain replacement fields surrounded by curly braces. The replacement fields are expressions, which are evaluated at run time, and then formatted using the format() protocol.
>>> name = "Fred"
>>> f"He said his name is {name}."
'He said his name is Fred.'
The new PYTHONMALLOC environment variable allows to set the Python memory allocators and/or install debug hooks.
It is now possible to install debug hooks on Python memory allocators on Python compiled in release mode using PYTHONMALLOC=debug. Effects of debug hooks:
- Newly allocated memory is filled with the byte 0xCB
- Freed memory is filled with the byte 0xDB
- Detect violations of Python memory allocator API. For example, PyObject_Free() called on a memory block allocated by PyMem_Malloc().
- Detect write before the start of the buffer (buffer underflow)
- Detect write after the end of the buffer (buffer overflow)
- Check that the GIL is held when allocator functions of PYMEM_DOMAIN_OBJ (ex: PyObject_Malloc()) and PYMEM_DOMAIN_MEM (ex: PyMem_Malloc()) domains are called.
원본링크: https://docs.python.org/dev/whatsnew/3.6.html
댓글 0