Skip to content

Commit 4494ce8

Browse files
sync with cpython 088c8ea1
1 parent aedfaa5 commit 4494ce8

3 files changed

Lines changed: 250 additions & 60 deletions

File tree

howto/free-threading-python.po

Lines changed: 191 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: Python 3.14\n"
99
"Report-Msgid-Bugs-To: \n"
10-
"POT-Creation-Date: 2025-12-03 00:14+0000\n"
10+
"POT-Creation-Date: 2026-05-31 00:40+0000\n"
1111
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
@@ -259,3 +259,193 @@ msgid ""
259259
"catch_warnings` modifies the global filters list, which is not thread-safe. "
260260
"See the :mod:`warnings` module for more details."
261261
msgstr ""
262+
263+
#: ../../howto/free-threading-python.rst:171
264+
msgid "Increased memory usage"
265+
msgstr ""
266+
267+
#: ../../howto/free-threading-python.rst:173
268+
msgid ""
269+
"The free-threaded build will typically use more memory compared to the "
270+
"default build. There are multiple reasons for this, mostly due to design "
271+
"decisions."
272+
msgstr ""
273+
274+
#: ../../howto/free-threading-python.rst:178
275+
msgid "All interned strings are immortal"
276+
msgstr ""
277+
278+
#: ../../howto/free-threading-python.rst:180
279+
msgid ""
280+
"For modern Python versions (since version 2.3), interning a string (e.g. "
281+
"with :func:`sys.intern`) does not cause it to become immortal. Instead, if "
282+
"the last reference to that string disappears, it will be removed from the "
283+
"interned string table. This is not the case for the free-threaded build and "
284+
"any interned string will become immortal, surviving until interpreter "
285+
"shutdown."
286+
msgstr ""
287+
288+
#: ../../howto/free-threading-python.rst:188
289+
msgid "Non-GC objects have a larger object header"
290+
msgstr ""
291+
292+
#: ../../howto/free-threading-python.rst:190
293+
msgid ""
294+
"The free-threaded build uses a different :c:type:`PyObject` structure. "
295+
"Instead of having the GC related information allocated before the :c:type:"
296+
"`PyObject` structure, like in the default build, the GC related info is part "
297+
"of the normal object header. For example, on the AMD64 platform, ``None`` "
298+
"uses 32 bytes on the free-threaded build vs 16 bytes for the default build. "
299+
"GC objects (such as dicts and lists) are the same size for both builds since "
300+
"the free-threaded build does not use additional space for the GC info."
301+
msgstr ""
302+
303+
#: ../../howto/free-threading-python.rst:200
304+
msgid "QSBR can delay freeing of memory"
305+
msgstr ""
306+
307+
#: ../../howto/free-threading-python.rst:202
308+
msgid ""
309+
"In order to safely implement lock-free data structures, a safe memory "
310+
"reclamation (SMR) scheme is used, known as quiescent state-based reclamation "
311+
"(QSBR). This means that the memory backing data structures allowing lock-"
312+
"free access will use QSBR, which defers the free operation, rather than "
313+
"immediately freeing the memory. Two examples of these data structures are "
314+
"the list object and the dictionary keys object. See ``InternalDocs/qsbr."
315+
"md`` in the CPython source tree for more details on how QSBR is "
316+
"implemented. Running :func:`gc.collect` should cause all memory being held "
317+
"by QSBR to be actually freed. Note that even when QSBR frees the memory, "
318+
"the underlying memory allocator may not immediately return that memory to "
319+
"the OS and so the resident set size (RSS) of the process might not decrease."
320+
msgstr ""
321+
322+
#: ../../howto/free-threading-python.rst:216
323+
msgid "mimalloc allocator vs pymalloc"
324+
msgstr ""
325+
326+
#: ../../howto/free-threading-python.rst:218
327+
msgid ""
328+
"The default build will normally use the \"pymalloc\" memory allocator for "
329+
"small allocations (512 bytes or smaller). The free-threaded build does not "
330+
"use pymalloc and allocates all Python objects using the \"mimalloc\" "
331+
"allocator. The pymalloc allocator has the following properties that help "
332+
"keep memory usage low: small per-allocated-block overhead, effective memory "
333+
"fragmentation prevention, and quick return of free memory to the operating "
334+
"system. The mimalloc allocator does quite well in these respects as well "
335+
"but can have some more overhead."
336+
msgstr ""
337+
338+
#: ../../howto/free-threading-python.rst:227
339+
msgid ""
340+
"In the free-threaded build, mimalloc manages memory in a number of separate "
341+
"heaps (currently four). For example, all GC supporting objects are "
342+
"allocated from their own heap. Using separate heaps means that free memory "
343+
"in one heap cannot be used for an allocation that uses another heap. Also, "
344+
"some heaps are configured to use QSBR (quiescent-state based reclamation) "
345+
"when freeing the memory that backs up the heap (known as \"pages\" in "
346+
"mimalloc terminology). The use of QSBR creates a delay between all memory "
347+
"blocks for a page being freed and the memory page being released, either for "
348+
"new allocations or back to the OS."
349+
msgstr ""
350+
351+
#: ../../howto/free-threading-python.rst:237
352+
msgid ""
353+
"The mimalloc allocator also defers returning freed memory back to the OS. "
354+
"You can reduce that delay by setting the environment variable :envvar:`!"
355+
"MIMALLOC_PURGE_DELAY` to ``0``. Note that this will likely reduce the "
356+
"performance of the allocator."
357+
msgstr ""
358+
359+
#: ../../howto/free-threading-python.rst:244
360+
msgid "Free-threaded reference counting can cause objects to live longer"
361+
msgstr ""
362+
363+
#: ../../howto/free-threading-python.rst:246
364+
msgid ""
365+
"In the default build, when an object's reference count reaches zero, it is "
366+
"normally deallocated. The free-threaded build uses \"biased reference "
367+
"counting\", with a fast-path for objects \"owned\" by the current thread and "
368+
"a slow path for other objects. See :pep:`703` for additional details. Any "
369+
"time an object's reference count ends up in a \"queued\" state, deallocation "
370+
"can be deferred. The queued state is cleared from the \"eval breaker\" "
371+
"section of the bytecode evaluator."
372+
msgstr ""
373+
374+
#: ../../howto/free-threading-python.rst:254
375+
msgid ""
376+
"The free-threaded build also allows a different mode of reference counting, "
377+
"known as \"deferred reference counting\". This mode is enabled by setting a "
378+
"flag on a per-object basis. Deferred reference counting is enabled for the "
379+
"following types:"
380+
msgstr ""
381+
382+
#: ../../howto/free-threading-python.rst:259
383+
msgid "module objects"
384+
msgstr ""
385+
386+
#: ../../howto/free-threading-python.rst:260
387+
msgid "module top-level functions"
388+
msgstr ""
389+
390+
#: ../../howto/free-threading-python.rst:261
391+
msgid "class methods defined in the class scope"
392+
msgstr ""
393+
394+
#: ../../howto/free-threading-python.rst:262
395+
msgid "descriptor objects"
396+
msgstr ""
397+
398+
#: ../../howto/free-threading-python.rst:263
399+
msgid "thread-local objects, created by :class:`threading.local`"
400+
msgstr ""
401+
402+
#: ../../howto/free-threading-python.rst:265
403+
msgid ""
404+
"When deferred reference counting is enabled, references from Python function "
405+
"stacks are not added to the reference count. This scheme reduces the "
406+
"overhead of reference counting, especially for objects used from multiple "
407+
"threads. Because the stack references are not counted, objects with deferred "
408+
"reference counting are not immediately freed when their internal reference "
409+
"count goes to zero. Instead, they are examined by the next GC run and, if "
410+
"no stack references to them are found, they are freed. This means these "
411+
"objects are freed by the GC and not when their reference count goes to zero, "
412+
"as is typical."
413+
msgstr ""
414+
415+
#: ../../howto/free-threading-python.rst:276
416+
msgid "Per-thread reference counting can delay freeing objects"
417+
msgstr ""
418+
419+
#: ../../howto/free-threading-python.rst:278
420+
msgid ""
421+
"To avoid contention on the reference count fields of frequently shared "
422+
"objects, the free-threaded build also uses \"per-thread reference counting\" "
423+
"for a few selected object types. Rather than updating a single shared "
424+
"reference count, each thread maintains its own local reference count array, "
425+
"indexed by a unique id assigned to the object. The true reference count is "
426+
"only computed by summing the per-thread counts when the object's local count "
427+
"drops to zero. Per-thread reference counting is currently used for:"
428+
msgstr ""
429+
430+
#: ../../howto/free-threading-python.rst:286
431+
msgid "heap type objects (classes created in Python)"
432+
msgstr ""
433+
434+
#: ../../howto/free-threading-python.rst:287
435+
msgid "code objects"
436+
msgstr ""
437+
438+
#: ../../howto/free-threading-python.rst:288
439+
msgid "the ``__dict__`` of module objects"
440+
msgstr ""
441+
442+
#: ../../howto/free-threading-python.rst:290
443+
msgid ""
444+
"Because the per-thread counts must be merged back to the object before it "
445+
"can be deallocated, objects using per-thread reference counting are "
446+
"typically freed later than they would be in the default build. In "
447+
"particular, such an object is usually not freed until the thread that "
448+
"referenced it reaches a safe point (for example, in the \"eval breaker\" "
449+
"section of the bytecode evaluator) or exits. Running :func:`gc.collect` "
450+
"will merge the per-thread counts and allow these objects to be freed."
451+
msgstr ""

0 commit comments

Comments
 (0)