GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — python-docs-fa/builtins/threadsafety.po at 3.14 · python/python-docs-fa Expand file tree/ Copy paththreadsafety.poMore file actions 641 lines (519 loc) · 46.2 KB / Copy paththreadsafety.poFile metadata and controls641 lines (519 loc) · 46.2 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 # Persian translations for Python package. # Copyright (C) 2001 Python Software Foundation # This file is distributed under the same license as the Python package. # Automatically generated, 2026. # # Translators: # Sepehr Rasouli <[email protected]>, 2026 # mahdyaralipor <[email protected]>, 2026 # msgid "" msgstr "" "Project-Id-Version: Python 3.14\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2026-09-30 04:09+0000\n" "PO-Revision-Date: 2026-09-19 20:08+0330\n" "Last-Translator: Sepehr Rasouli <[email protected]>, 2026\n" "Language-Team: none\n" "Language: fa\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" msgid "Thread Safety Guarantees" msgstr "تضمینهای ایمنی نخ" msgid "This page documents thread-safety guarantees for built-in types in Python's free-threaded build. The guarantees described here apply when using Python with the :term:`GIL` disabled (free-threaded mode). When the GIL is enabled, most operations are implicitly serialized." msgstr "این صفحه تضمینهای ایمنی نخی برای انواع توکار در ساخت نخآزاد (free-threaded) پایتون را مستند میکند. تضمینهای توصیفشده در اینجا زمانی اعمال میشوند که از پایتون با :term:`GIL` غیرفعال (حالت نخآزاد) استفاده میکنید. هنگامی که GIL فعال باشد، بیشتر عملیاتها بهطور ضمنی بهصورت سریالی اجرا میشوند." msgid "For general guidance on writing thread-safe code in free-threaded Python, see :ref:`freethreading-python-howto`." msgstr "برای راهنمایی کلی درباره نوشتن کد نخایمن (thread-safe) در پایتون نخآزاد، به :ref:`freethreading-python-howto` مراجعه کنید." msgid "Thread safety levels" msgstr "سطوح ایمنی نخ" msgid "The C API documentation uses the following levels to describe the thread safety guarantees of each function. The levels are listed from least to most safe." msgstr "مستندات C API از سطوح زیر برای توصیف تضمینهای ایمنی نخی هر تابع استفاده میکند. این سطوح از کمایمنترین تا ایمنترین فهرست شدهاند." msgid "Incompatible" msgstr "ناسازگار" msgid "A function or operation that cannot be made safe for concurrent use even with external synchronization. Incompatible code typically accesses global state in an unsynchronized way and must only be called from a single thread throughout the program's lifetime." msgstr "تابع یا عملیاتی که حتی با همگامسازی خارجی نیز نمیتوان آن را برای استفاده همزمان ایمن کرد. کد ناسازگار معمولاً به وضعیت سراسری بهصورت همگامنشده دسترسی پیدا میکند و باید در طول عمر برنامه تنها از یک نخ فراخوانی شود." msgid "Example: a function that modifies process-wide state such as signal handlers or environment variables, where concurrent calls from any threads, even with external locking, can conflict with the runtime or other libraries." msgstr "مثال: تابعی که وضعیت سراسریِ فرایند را تغییر میدهد، مانند هندلرهای سیگنال یا متغیرهای محیطی، که در آن فراخوانیهای همزمان از هر نخی، حتی با قفلگذاری خارجی، میتوانند با رانتایم یا کتابخانههای دیگر تداخل داشته باشند." msgid "Compatible" msgstr "سازگار" msgid "A function or operation that is safe to call from multiple threads *provided* the caller supplies appropriate external synchronization, for example by holding a :term:`lock` for the duration of each call. Without such synchronization, concurrent calls may produce :term:`race conditions <race condition>` or :term:`data races <data race>`." msgstr "تابع یا عملیاتی که فراخوانی آن از چندین نخ ایمن است، *مشروط بر اینکه* فراخواننده همگامسازی خارجی مناسبی را فراهم کند، برای مثال با نگهداشتن یک :term:`قفل <lock>` در طول مدت هر فراخوانی. بدون چنین همگامسازیای، فراخوانیهای همزمان ممکن است باعث ایجاد :term:`شرایط رقابتی <race condition>` یا :term:`رقابتهای دادهای <data race>` شوند." msgid "Example: a function that reads from or writes to an object whose internal state is not protected by a lock. Callers must ensure that no two threads access the same object at the same time." msgstr "مثال: تابعی که از یک شیء میخواند یا در آن مینویسد، و وضعیت داخلی آن شیء با یک قفل محافظت نمیشود. فراخوانیکنندگان باید اطمینان حاصل کنند که هیچ دو نخی بهطور همزمان به همان شیء دسترسی نداشته باشند." msgid "Safe on distinct objects" msgstr "ایمن برای اشیاء متمایز" msgid "A function or operation that is safe to call from multiple threads without external synchronization, as long as each thread operates on a **different** object. Two threads may call the function at the same time, but they must not pass the same object (or objects that share underlying state) as arguments." msgstr "تابع یا عملیاتی که فراخوانی آن از چند نخ بدون همگامسازی خارجی امن است، مشروط بر اینکه هر نخ روی یک شیء **متفاوت** عمل کند. دو نخ میتوانند تابع را همزمان فراخوانی کنند، اما نباید شیء یکسان (یا اشیایی که وضعیت زیربنایی مشترکی دارند) را بهعنوان آرگومان ارسال کنند." msgid "Example: a function that modifies fields of a struct using non-atomic writes. Two threads can each call the function on their own struct instance safely, but concurrent calls on the *same* instance require external synchronization." msgstr "مثال: تابعی که فیلدهای یک ساختار را با استفاده از نوشتنهای غیراتمی تغییر میدهد. دو نخ میتوانند هر کدام تابع را روی نمونهی ساختار خود بهصورت ایمن فراخوانی کنند، اما فراخوانیهای همزمان روی *همان* نمونه به همگامسازی خارجی نیاز دارند." msgid "Safe on shared objects" msgstr "ایمن روی اشیاء مشترک" msgid "A function or operation that is safe for concurrent use on the **same** object. The implementation uses internal synchronization (such as :term:`per-object locks <per-object lock>` or :ref:`critical sections <python-critical-section-api>`) to protect shared mutable state, so callers do not need to supply their own locking." msgstr "تابع یا عملیاتی که برای استفاده همزمان روی **همان** شیء ایمن است. پیادهسازی از همگامسازی داخلی (مانند :term:`قفلهای بهازای هر شیء <per-object lock>` یا :ref:`بخشهای بحرانی <python-critical-section-api>`) برای محافظت از وضعیت تغییرپذیر مشترک استفاده میکند، بنابراین فراخوانکنندگان نیازی به فراهم کردن قفلگذاری خودشان ندارند." msgid "Example: :c:func:`PyList_GetItemRef` can be called from multiple threads on the same :c:type:`PyListObject` - it uses internal synchronization to serialize access." msgstr "مثال: میتوان :c:func:`PyList_GetItemRef` را از چندین نخ روی همان :c:type:`PyListObject` فراخوانی کرد - این تابع از همگامسازی داخلی برای متوالیکردن دسترسی استفاده میکند." msgid "Atomic" msgstr "اتمی" msgid "A function or operation that appears :term:`atomic <atomic operation>` with respect to other threads - it executes instantaneously from the perspective of other threads. This is the strongest form of thread safety." msgstr "تابع یا عملیاتی که نسبت به سایر نخها بهصورت :term:`اتمی <atomic operation>` به نظر میرسد؛ از دید سایر نخها بهصورت آنی اجرا میشود. این قویترین شکل ایمنی نخی است." msgid "Example: :c:func:`PyMutex_IsLocked` performs an atomic read of the mutex state and can be called from any thread at any time." msgstr "مثال: :c:func:`PyMutex_IsLocked` یک خواندن اتمی از وضعیت قفل متقابل (mutex) انجام میدهد و میتواند از هر نخی در هر زمانی فراخوانی شود." msgid "Thread safety for list objects" msgstr "ایمنی در برابر نخها برای اشیای فهرست" msgid "Reading a single element from a :class:`list` is :term:`atomic <atomic operation>`:" msgstr "خواندن یک عنصر از یک :class:`list` :term:`اتمی <atomic operation>` است:" msgid "lst[i] # list.__getitem__" msgstr "lst[i] # list.__getitem__" msgid "The following methods traverse the list and use :term:`atomic <atomic operation>` reads of each item to perform their function. That means that they may return results affected by concurrent modifications:" msgstr "متدهای زیر فهرست را پیمایش میکنند و از خواندنهای :term:`اتمی <atomic operation>` هر آیتم برای انجام وظیفه خود استفاده میکنند. این بدان معناست که ممکن است نتایجی برگردانند که تحت تأثیر تغییرات همزمان قرار گرفتهاند:" msgid "" "item in lst\n" "lst.index(item)\n" "lst.count(item)" msgstr "" "item in lst\n" "lst.index(item)\n" "lst.count(item)" msgid "All of the above operations avoid acquiring :term:`per-object locks <per-object lock>`. They do not block concurrent modifications. Other operations that hold a lock will not block these from observing intermediate states." msgstr "همهی عملیاتهای بالا از کسب :term:`قفلهای بهازای هر شیء <per-object lock>` خودداری میکنند. آنها تغییرات همزمان را مسدود نمیکنند. سایر عملیاتهایی که قفلی را در اختیار دارند، این عملیاتها را از مشاهدهی وضعیتهای میانی باز نمیدارند." msgid "All other operations from here on block using the :term:`per-object lock`." msgstr "از این پس، همهی عملیاتهای دیگر با استفاده از :term:`per-object lock` مسدود میشوند." msgid "Writing a single item via ``lst[i] = x`` is safe to call from multiple threads and will not corrupt the list." msgstr "نوشتن یک آیتم واحد از طریق ``lst[i] = x`` برای فراخوانی از چندین نخ ایمن است و فهرست را خراب نمیکند." msgid "The following operations return new objects and appear :term:`atomic <atomic operation>` to other threads:" msgstr "عملیات زیر اشیای جدیدی را برمیگردانند و برای نخهای دیگر :term:`اتمی <atomic operation>` به نظر میرسند:" msgid "" "lst1 + lst2 # concatenates two lists into a new list\n" "x * lst # repeats lst x times into a new list\n" "lst.copy() # returns a shallow copy of the list" msgstr "" "lst1 + lst2 # concatenates two lists into a new list\n" "x * lst # repeats lst x times into a new list\n" "lst.copy() # returns a shallow copy of the list" msgid "The following methods that only operate on a single element with no shifting required are :term:`atomic <atomic operation>`:" msgstr "متدهای زیر که تنها روی یک المان عمل میکنند و نیازی به جابهجایی ندارند، :term:`اتمی <atomic operation>` هستند:" msgid "" "lst.append(x) # append to the end of the list, no shifting required\n" "lst.pop() # pop element from the end of the list, no shifting required" msgstr "" "lst.append(x) # append to the end of the list, no shifting required\n" "lst.pop() # pop element from the end of the list, no shifting required" msgid "The :meth:`~list.clear` method is also :term:`atomic <atomic operation>`. Other threads cannot observe elements being removed." msgstr "متد :meth:`~list.clear` نیز :term:`اتمی <atomic operation>` است. سایر نخها نمیتوانند حذف شدن عناصر را مشاهده کنند." msgid "The :meth:`~list.sort` method is not :term:`atomic <atomic operation>`. Other threads cannot observe intermediate states during sorting, but the list appears empty for the duration of the sort." msgstr "متد :meth:`~list.sort` :term:`اتمی <atomic operation>` نیست. سایر نخها نمیتوانند وضعیتهای میانی را در حین مرتبسازی مشاهده کنند، اما فهرست در طول مدت مرتبسازی خالی به نظر میرسد." msgid "The following operations may allow :term:`lock-free` operations to observe intermediate states since they modify multiple elements in place:" msgstr "عملیاتهای زیر ممکن است به عملیات :term:`lock-free` اجازه دهند که وضعیتهای میانی را مشاهده کنند، زیرا چندین المان را بهصورت درجا تغییر میدهند:" msgid "" "lst.insert(idx, item) # shifts elements\n" "lst.pop(idx) # idx not at the end of the list, shifts elements\n" "lst *= x # copies elements in place" msgstr "" "lst.insert(idx, item) # shifts elements\n" "lst.pop(idx) # idx not at the end of the list, shifts elements\n" "lst *= x # copies elements in place" msgid "The :meth:`~list.remove` method may allow concurrent modifications since element comparison may execute arbitrary Python code (via :meth:`~object.__eq__`)." msgstr "متد :meth:`~list.remove` ممکن است اجازهی تغییرات همزمان را بدهد، زیرا مقایسهی عنصر ممکن است کد پایتون دلخواه را اجرا کند (از طریق :meth:`~object.__eq__`)." msgid ":meth:`~list.extend` is safe to call from multiple threads. However, its guarantees depend on the iterable passed to it. If it is a :class:`list`, a :class:`tuple`, a :class:`set`, a :class:`frozenset`, a :class:`dict` or a :ref:`dictionary view object <dict-views>` (but not their subclasses), the ``extend`` operation is safe from concurrent modifications to the iterable. Otherwise, an iterator is created which can be concurrently modified by another thread. The same applies to inplace concatenation of a list with other iterables when using ``lst += iterable``." msgstr "فراخوانی :meth:`~list.extend` از چندین نخ ایمن است. با این حال، تضمینهای آن به پیمایشپذیری که به آن داده میشود بستگی دارد. اگر این پیمایشپذیر یک :class:`list`، :class:`tuple`، :class:`set`، :class:`frozenset`، :class:`dict` یا :ref:`شیء نمای دیکشنری <dict-views>` باشد (اما نه زیرکلاسهای آنها)، عملیات ``extend`` در برابر تغییرات همزمان روی پیمایشپذیر ایمن است. در غیر این صورت، یک پیمایشگر ایجاد میشود که ممکن است توسط نخ دیگری بهطور همزمان تغییر داده شود. همین موضوع برای الحاق درجای یک فهرست با سایر پیمایشپذیرها هنگام استفاده از ``lst += iterable`` نیز صدق میکند." msgid "Similarly, assigning to a list slice with ``lst[i:j] = iterable`` is safe to call from multiple threads, but ``iterable`` is only locked when it is also a :class:`list` (but not its subclasses)." msgstr "بهطور مشابه، انتساب به یک اسلایس فهرست با ``lst[i:j] = iterable`` برای فراخوانی از چندین نخ امن است، اما ``iterable`` تنها زمانی قفل میشود که خود نیز یک :class:`list` باشد (اما نه زیرکلاسهای آن)." msgid "Operations that involve multiple accesses, as well as iteration, are never atomic. For example:" msgstr "عملیاتهایی که شامل چندین دسترسی و همچنین تکرار هستند، هرگز اتمی نیستند. برای مثال:" msgid "" "# NOT atomic: read-modify-write\n" "lst[i] = lst[i] + 1\n" "\n" "# NOT atomic: check-then-act\n" "if lst:\n" " item = lst.pop()\n" "\n" "# NOT thread-safe: iteration while modifying\n" "for item in lst:\n" " process(item) # another thread may modify lst" msgstr "" "# NOT atomic: read-modify-write\n" "lst[i] = lst[i] + 1\n" "\n" "# NOT atomic: check-then-act\n" "if lst:\n" " item = lst.pop()\n" "\n" "# NOT thread-safe: iteration while modifying\n" "for item in lst:\n" " process(item) # another thread may modify lst" msgid "Consider external synchronization when sharing :class:`list` instances across threads." msgstr "هنگام اشتراکگذاری نمونههای :class:`list` میان نخها، همگامسازی خارجی را در نظر بگیرید." msgid "Thread safety for dict objects" msgstr "ایمنی نخی برای اشیاء دیکشنری" msgid "Creating a dictionary with the :class:`dict` constructor is atomic when the argument to it is a :class:`dict` or a :class:`tuple`. When using the :meth:`dict.fromkeys` method, dictionary creation is atomic when the argument is a :class:`dict`, :class:`tuple`, :class:`set` or :class:`frozenset`." msgstr "ایجاد یک دیکشنری با سازندهی :class:`dict` زمانی اتمی است که آرگومان آن یک :class:`dict` یا یک :class:`tuple` باشد. هنگام استفاده از متد :meth:`dict.fromkeys`، ایجاد دیکشنری زمانی اتمی است که آرگومان یک :class:`dict`، :class:`tuple`، :class:`set` یا :class:`frozenset` باشد." msgid "The following operations and functions are :term:`lock-free` and :term:`atomic <atomic operation>`." msgstr "عملیات و توابع زیر :term:`بدون قفل <lock-free>` و :term:`اتمی <atomic operation>` هستند." msgid "" "d[key] # dict.__getitem__\n" "d.get(key) # dict.get\n" "key in d # dict.__contains__\n" "len(d) # dict.__len__" msgstr "" "d[key] # dict.__getitem__\n" "d.get(key) # dict.get\n" "key in d # dict.__contains__\n" "len(d) # dict.__len__" msgid "All other operations from here on hold the :term:`per-object lock`." msgstr "تمام عملیاتهای دیگر از اینجا به بعد، :term:`per-object lock` را در اختیار دارند." msgid "Writing or removing a single item is safe to call from multiple threads and will not corrupt the dictionary:" msgstr "نوشتن یا حذف یک آیتم واحد برای فراخوانی از چندین نخ ایمن است و دیکشنری را خراب نمیکند:" msgid "" "d[key] = value # write\n" "del d[key] # delete\n" "d.pop(key) # remove and return\n" "d.popitem() # remove and return last item\n" "d.setdefault(key, v) # insert if missing" msgstr "" "d[key] = value # write\n" "del d[key] # delete\n" "d.pop(key) # remove and return\n" "d.popitem() # remove and return last item\n" "d.setdefault(key, v) # insert if missing" msgid "These operations may compare keys using :meth:`~object.__eq__`, which can execute arbitrary Python code. During such comparisons, the dictionary may be modified by another thread. For built-in types like :class:`str`, :class:`int`, and :class:`float`, that implement :meth:`~object.__eq__` in C, the underlying lock is not released during comparisons and this is not a concern." msgstr "این عملیاتها ممکن است کلیدها را با استفاده از :meth:`~object.__eq__` مقایسه کنند، که میتواند کد پایتون دلخواه را اجرا کند. در حین چنین مقایسههایی، ممکن است دیکشنری توسط نخ دیگری تغییر داده شود. برای انواع توکار مانند :class:`str`، :class:`int` و :class:`float`، که :meth:`~object.__eq__` را در C پیادهسازی میکنند، قفل زیربنایی در حین مقایسهها آزاد نمیشود و این موضوع جای نگرانی نیست." msgid "The following operations return new objects and hold the :term:`per-object lock` for the duration of the operation:" msgstr "عملیاتهای زیر شیءهای جدید را برمیگردانند و در طول مدت عملیات، :term:`per-object lock` را نگه میدارند:" msgid "" "d.copy() # returns a shallow copy of the dictionary\n" "d | other # merges two dicts into a new dict\n" "d.keys() # returns a new dict_keys view object\n" "d.values() # returns a new dict_values view object\n" "d.items() # returns a new dict_items view object" msgstr "" "d.copy() # returns a shallow copy of the dictionary\n" "d | other # merges two dicts into a new dict\n" "d.keys() # returns a new dict_keys view object\n" "d.values() # returns a new dict_values view object\n" "d.items() # returns a new dict_items view object" msgid "The :meth:`~dict.clear` method holds the lock for its duration. Other threads cannot observe elements being removed." msgstr "متد :meth:`~dict.clear` قفل را در طول مدت اجرای خود نگه میدارد. نخهای دیگر نمیتوانند حذف عناصر را مشاهده کنند." msgid "The following operations lock both dictionaries. For :meth:`~dict.update` and ``|=``, this applies only when the other operand is a :class:`dict` that uses the standard dict iterator (but not subclasses that override iteration). For equality comparison, this applies to :class:`dict` and its subclasses:" msgstr "عملیات زیر هر دو دیکشنری را قفل میکنند. برای :meth:`~dict.update` و ``|=``، این موضوع فقط زمانی صدق میکند که عملوند دیگر یک :class:`dict` باشد که از پیمایشگر استاندارد دیکشنری استفاده میکند (اما نه زیرکلاسهایی که پیمایش را بازنویسی میکنند). در مقایسه برابری، این موضوع برای :class:`dict` و زیرکلاسهای آن صدق میکند:" msgid "" "d.update(other_dict) # both locked when other_dict is a dict\n" "d |= other_dict # both locked when other_dict is a dict\n" "d == other_dict # both locked for dict and subclasses" msgstr "" "d.update(other_dict) # both locked when other_dict is a dict\n" "d |= other_dict # both locked when other_dict is a dict\n" "d == other_dict # both locked for dict and subclasses" msgid "All comparison operations also compare values using :meth:`~object.__eq__`, so for non-built-in types the lock may be released during comparison." msgstr "تمام عملیاتهای مقایسه نیز مقادیر را با استفاده از :meth:`~object.__eq__` مقایسه میکنند، بنابراین برای انواع غیرتوکار ممکن است قفل در حین مقایسه آزاد شود." msgid ":meth:`~dict.fromkeys` locks both the new dictionary and the iterable when the iterable is exactly a :class:`dict`, :class:`set`, or :class:`frozenset` (not subclasses):" msgstr ":meth:`~dict.fromkeys` هر دو دیکشنری جدید و پیمایشپذیر را زمانی که پیمایشپذیر دقیقاً یک :class:`dict`، :class:`set` یا :class:`frozenset` باشد (نه زیرکلاسها) قفل میکند:" msgid "" "dict.fromkeys(a_dict) # locks both\n" "dict.fromkeys(a_set) # locks both\n" "dict.fromkeys(a_frozenset) # locks both" msgstr "" "dict.fromkeys(a_dict) # locks both\n" "dict.fromkeys(a_set) # locks both\n" "dict.fromkeys(a_frozenset) # locks both" msgid "When updating from a non-dict iterable, only the target dictionary is locked. The iterable may be concurrently modified by another thread:" msgstr "هنگام بهروزرسانی از یک پیمایشپذیر غیر از دیکشنری، فقط دیکشنری هدف قفل میشود. ممکن است پیمایشپذیر بهطور همزمان توسط نخ دیگری تغییر داده شود:" msgid "" "d.update(iterable) # iterable is not a dict: only d locked\n" "d |= iterable # iterable is not a dict: only d locked\n" "dict.fromkeys(iterable) # iterable is not a dict/set/frozenset: only result locked" msgstr "" "d.update(iterable) # iterable is not a dict: only d locked\n" "d |= iterable # iterable is not a dict: only d locked\n" "dict.fromkeys(iterable) # iterable is not a dict/set/frozenset: only result locked" msgid "Operations that involve multiple accesses, as well as iteration, are never atomic:" msgstr "عملیاتهایی که شامل چندین دسترسی هستند، و همچنین پیمایش، هرگز اتمی نیستند:" msgid "" "# NOT atomic: read-modify-write\n" "d[key] = d[key] + 1\n" "\n" "# NOT atomic: check-then-act (TOCTOU)\n" "if key in d:\n" " del d[key]\n" "\n" "# NOT thread-safe: iteration while modifying\n" "for key, value in d.items():\n" " process(key) # another thread may modify d" msgstr "" "# NOT atomic: read-modify-write\n" "d[key] = d[key] + 1\n" "\n" "# NOT atomic: check-then-act (TOCTOU)\n" "if key in d:\n" " del d[key]\n" "\n" "# NOT thread-safe: iteration while modifying\n" "for key, value in d.items():\n" " process(key) # another thread may modify d" msgid "To avoid time-of-check to time-of-use (TOCTOU) issues, use atomic operations or handle exceptions:" msgstr "برای جلوگیری از مشکلات زمان بررسی تا زمان استفاده (TOCTOU)، از عملیات اتمی استفاده کنید یا استثناها را مدیریت کنید:" msgid "" "# Use pop() with default instead of check-then-delete\n" "d.pop(key, None)\n" "\n" "# Or handle the exception\n" "try:\n" " del d[key]\n" "except KeyError:\n" " pass" msgstr "" "# Use pop() with default instead of check-then-delete\n" "d.pop(key, None)\n" "\n" "# Or handle the exception\n" "try:\n" " del d[key]\n" "except KeyError:\n" " pass" msgid "To safely iterate over a dictionary that may be modified by another thread, iterate over a copy:" msgstr "برای پیمایش ایمن روی دیکشنریای که ممکن است توسط نخ دیگری تغییر داده شود، روی یک نسخه از آن پیمایش کنید:" msgid "" "# Make a copy to iterate safely\n" "for key, value in d.copy().items():\n" " process(key)" msgstr "" "# Make a copy to iterate safely\n" "for key, value in d.copy().items():\n" " process(key)" msgid "Consider external synchronization when sharing :class:`dict` instances across threads." msgstr "هنگام اشتراکگذاری نمونههای :class:`dict` میان نخها، همگامسازی خارجی را در نظر بگیرید." msgid "Thread safety for set objects" msgstr "ایمنی نخی برای اشیای مجموعه" msgid "The :func:`len` function is lock-free and :term:`atomic <atomic operation>`." msgstr "تابع :func:`len` بدون قفل و :term:`اتمی <atomic operation>` است." msgid "The following read operation is lock-free. It does not block concurrent modifications and may observe intermediate states from operations that hold the per-object lock:" msgstr "عملیات خواندن زیر بدون قفل است. این عملیات تغییرات همزمان را مسدود نمیکند و ممکن است وضعیتهای میانیِ عملیاتی را که قفل بهازای هر شیء را در اختیار دارند، مشاهده کند:" msgid "elem in s # set.__contains__" msgstr "elem in s # set.__contains__" msgid "This operation may compare elements using :meth:`~object.__eq__`, which can execute arbitrary Python code. During such comparisons, the set may be modified by another thread. For built-in types like :class:`str`, :class:`int`, and :class:`float`, :meth:`!__eq__` does not release the underlying lock during comparisons and this is not a concern." msgstr "این عملیات ممکن است عناصر را با استفاده از :meth:`~object.__eq__`، که میتواند کد پایتون دلخواه را اجرا کند، مقایسه کند. در طول چنین مقایسههایی، ممکن است مجموعه توسط نخ دیگری تغییر کند. برای انواع توکار مانند :class:`str`، :class:`int` و :class:`float`، :meth:`!__eq__` قفل زیرین را در طول مقایسهها آزاد نمیکند و این جای نگرانی نیست." msgid "All other operations from here on hold the per-object lock." msgstr "از این نقطه به بعد، تمام عملیاتهای دیگر قفل بهازای هر شیء را نگه میدارند." msgid "Adding or removing a single element is safe to call from multiple threads and will not corrupt the set:" msgstr "افزودن یا حذف یک المان منفرد را میتوان بهصورت امن از چند نخ فراخوانی کرد و مجموعه خراب نمیشود:" msgid "" "s.add(elem) # add element\n" "s.remove(elem) # remove element, raise if missing\n" "s.discard(elem) # remove element if present\n" "s.pop() # remove and return arbitrary element" msgstr "" "s.add(elem) # add element\n" "s.remove(elem) # remove element, raise if missing\n" "s.discard(elem) # remove element if present\n" "s.pop() # remove and return arbitrary element" msgid "These operations also compare elements, so the same :meth:`~object.__eq__` considerations as above apply." msgstr "این عملیاتها همچنین عناصر را مقایسه میکنند، بنابراین همان ملاحظات :meth:`~object.__eq__` بالا اعمال میشوند." msgid "The :meth:`~set.copy` method returns a new object and holds the per-object lock for the duration so that it is always atomic." msgstr "متد :meth:`~set.copy` یک شیء جدید بازمیگرداند و قفل بهازای هر شیء را در طول این مدت نگه میدارد تا همیشه اتمی باشد." msgid "The :meth:`~set.clear` method holds the lock for its duration. Other threads cannot observe elements being removed." msgstr "متد :meth:`~set.clear` قفل را در طول مدت اجرای خود نگه میدارد. سایر نخها نمیتوانند عناصر در حال حذف را مشاهده کنند." msgid "The following operations only accept :class:`set` or :class:`frozenset` as operands and always lock both objects:" msgstr "عملیاتهای زیر فقط :class:`set` یا :class:`frozenset` را بهعنوان عملوند میپذیرند و همیشه هر دو شیء را قفل میکنند:" msgid "" "s |= other # other must be set/frozenset\n" "s &= other # other must be set/frozenset\n" "s -= other # other must be set/frozenset\n" "s ^= other # other must be set/frozenset\n" "s & other # other must be set/frozenset\n" "s | other # other must be set/frozenset\n" "s - other # other must be set/frozenset\n" "s ^ other # other must be set/frozenset" msgstr "" "s |= other # other must be set/frozenset\n" "s &= other # other must be set/frozenset\n" "s -= other # other must be set/frozenset\n" "s ^= other # other must be set/frozenset\n" "s & other # other must be set/frozenset\n" "s | other # other must be set/frozenset\n" "s - other # other must be set/frozenset\n" "s ^ other # other must be set/frozenset" msgid ":meth:`set.update`, :meth:`set.union`, :meth:`set.intersection` and :meth:`set.difference` can take multiple iterables as arguments. They all iterate through all the passed iterables and do the following:" msgstr ":meth:`set.update`، :meth:`set.union`، :meth:`set.intersection` و :meth:`set.difference` میتوانند چندین پیمایشپذیر را بهعنوان آرگومان بگیرند. همهی آنها تمام پیمایشپذیرهای دادهشده را پیمایش میکنند و کار زیر را انجام میدهند:" msgid ":meth:`set.update` and :meth:`set.union` lock both objects only when the other operand is a :class:`set`, :class:`frozenset`, or :class:`dict`." msgstr ":meth:`set.update` و :meth:`set.union` هر دو شیء را تنها زمانی قفل میکنند که عملوند دیگر یک :class:`set`، :class:`frozenset` یا :class:`dict` باشد." msgid ":meth:`set.intersection` and :meth:`set.difference` always try to lock all objects." msgstr ":meth:`set.intersection` و :meth:`set.difference` همیشه سعی میکنند همهی اشیاء را قفل کنند." msgid ":meth:`set.symmetric_difference` tries to lock both objects." msgstr ":meth:`set.symmetric_difference` تلاش میکند هر دو شیء را قفل کند." msgid "The update variants of the above methods also have some differences between them:" msgstr "گونههای بهروزرسانی متدهای بالا نیز تفاوتهایی با یکدیگر دارند:" msgid ":meth:`set.difference_update` and :meth:`set.intersection_update` try to lock all objects one-by-one." msgstr ":meth:`set.difference_update` و :meth:`set.intersection_update` سعی میکنند همهی اشیاء را یکییکی قفل کنند." msgid ":meth:`set.symmetric_difference_update` only locks the arguments if it is of type :class:`set`, :class:`frozenset`, or :class:`dict`." msgstr ":meth:`set.symmetric_difference_update` آرگومانها را تنها در صورتی قفل میکند که از نوع :class:`set`، :class:`frozenset` یا :class:`dict` باشند." msgid "The following methods always try to lock both objects:" msgstr "متدهای زیر همیشه تلاش میکنند هر دو شیء را قفل کنند:" msgid "" "s.isdisjoint(other) # both locked\n" "s.issubset(other) # both locked\n" "s.issuperset(other) # both locked" msgstr "" "s.isdisjoint(other) # both locked\n" "s.issubset(other) # both locked\n" "s.issuperset(other) # both locked" msgid "" "# NOT atomic: check-then-act\n" "if elem in s:\n" " s.remove(elem)\n" "\n" "# NOT thread-safe: iteration while modifying\n" "for elem in s:\n" " process(elem) # another thread may modify s" msgstr "" "# NOT atomic: check-then-act\n" "if elem in s:\n" " s.remove(elem)\n" "\n" "# NOT thread-safe: iteration while modifying\n" "for elem in s:\n" " process(elem) # another thread may modify s" msgid "Consider external synchronization when sharing :class:`set` instances across threads. See :ref:`freethreading-python-howto` for more information." msgstr "هنگام اشتراکگذاری نمونههای :class:`set` بین نخها، همگامسازی خارجی را در نظر بگیرید. برای اطلاعات بیشتر :ref:`freethreading-python-howto` را ببینید." msgid "Thread safety for bytearray objects" msgstr "ایمنی نخی برای اشیاء bytearray" msgid "Concatenation and comparisons use the buffer protocol, which prevents resizing but does not hold the per-object lock. These operations may observe intermediate states from concurrent modifications:" msgstr "الحاق و مقایسهها از پروتکل بافر استفاده میکنند، که از تغییر اندازه جلوگیری میکند اما قفل بهازای هر شیء را نگه نمیدارد. این عملیات ممکن است وضعیتهای میانی ناشی از تغییرات همزمان را مشاهده کنند:" msgid "" "ba + other # may observe concurrent writes\n" "ba == other # may observe concurrent writes\n" "ba < other # may observe concurrent writes" msgstr "" "ba + other # may observe concurrent writes\n" "ba == other # may observe concurrent writes\n" "ba < other # may observe concurrent writes" msgid "Reading a single element or slice is safe to call from multiple threads:" msgstr "خواندن یک عنصر یا اسلایس برای فراخوانی از چندین نخ امن است:" msgid "" "ba[i] # bytearray.__getitem__\n" "ba[i:j] # slice" msgstr "" "ba[i] # bytearray.__getitem__\n" "ba[i:j] # slice" msgid "The following operations are safe to call from multiple threads and will not corrupt the bytearray:" msgstr "فراخوانی عملیات زیر از چندین نخ ایمن است و bytearray را خراب نمیکند:" msgid "" "ba[i] = x # write single byte\n" "ba[i:j] = values # write slice\n" "ba.append(x) # append single byte\n" "ba.extend(other) # extend with iterable\n" "ba.insert(i, x) # insert single byte\n" "ba.pop() # remove and return last byte\n" "ba.pop(i) # remove and return byte at index\n" "ba.remove(x) # remove first occurrence\n" "ba.reverse() # reverse in place\n" "ba.clear() # remove all bytes" msgstr "" "ba[i] = x # write single byte\n" "ba[i:j] = values # write slice\n" "ba.append(x) # append single byte\n" "ba.extend(other) # extend with iterable\n" "ba.insert(i, x) # insert single byte\n" "ba.pop() # remove and return last byte\n" "ba.pop(i) # remove and return byte at index\n" "ba.remove(x) # remove first occurrence\n" "ba.reverse() # reverse in place\n" "ba.clear() # remove all bytes" msgid "Slice assignment locks both objects when *values* is a :class:`bytearray`:" msgstr "انتساب اسلایسی هنگامی که *values* یک :class:`bytearray` باشد، هر دو شیء را قفل میکند:" msgid "ba[i:j] = other_bytearray # both locked" msgstr "ba[i:j] = other_bytearray # هر دو قفل هستند" msgid "The following operations return new objects and hold the per-object lock for the duration:" msgstr "عملیات زیر اشیای جدید را برمیگردانند و قفل بهازای هر شیء را در طول مدت آن نگه میدارند:" msgid "" "ba.copy() # returns a shallow copy\n" "ba * n # repeat into new bytearray" msgstr "" "ba.copy() # returns a shallow copy\n" "ba * n # repeat into new bytearray" msgid "The membership test holds the lock for its duration:" msgstr "آزمون عضویت، قفل را در طول مدت خود نگه میدارد:" msgid "x in ba # bytearray.__contains__" msgstr "x in ba # bytearray.__contains__" msgid "All other bytearray methods (such as :meth:`~bytearray.find`, :meth:`~bytearray.replace`, :meth:`~bytearray.split`, :meth:`~bytearray.decode`, etc.) hold the per-object lock for their duration." msgstr "تمام متدهای دیگر bytearray (مانند :meth:`~bytearray.find`، :meth:`~bytearray.replace`، :meth:`~bytearray.split`، :meth:`~bytearray.decode` و غیره) در طول اجرای خود، قفل بهازای هر شیء را نگه میدارند." msgid "" "# NOT atomic: check-then-act\n" "if x in ba:\n" " ba.remove(x)\n" "\n" "# NOT thread-safe: iteration while modifying\n" "for byte in ba:\n" " process(byte) # another thread may modify ba" msgstr "" "# NOT atomic: check-then-act\n" "if x in ba:\n" " ba.remove(x)\n" "\n" "# NOT thread-safe: iteration while modifying\n" "for byte in ba:\n" " process(byte) # another thread may modify ba" msgid "To safely iterate over a bytearray that may be modified by another thread, iterate over a copy:" msgstr "برای پیمایش امن روی bytearray که ممکن است توسط نخ دیگری تغییر کند، روی یک کپی پیمایش کنید:" msgid "" "# Make a copy to iterate safely\n" "for byte in ba.copy():\n" " process(byte)" msgstr "" "# Make a copy to iterate safely\n" "for byte in ba.copy():\n" " process(byte)" msgid "Consider external synchronization when sharing :class:`bytearray` instances across threads. See :ref:`freethreading-python-howto` for more information." msgstr "هنگام اشتراکگذاری نمونههای :class:`bytearray` بین نخها، همگامسازی خارجی را در نظر بگیرید. برای اطلاعات بیشتر :ref:`freethreading-python-howto` را ببینید." msgid "Thread safety for memoryview objects" msgstr "ایمنی نخ برای اشیای memoryview" msgid ":class:`memoryview` objects provide access to the internal data of an underlying object without copying. Thread safety depends on both the memoryview itself and the underlying buffer exporter." msgstr "اشیای :class:`memoryview` دسترسی به دادههای داخلی یک شیء زیربنایی را بدون کپی کردن فراهم میکنند. ایمنی نخی هم به خود memoryview و هم به اکسپورتکنندهی بافر زیربنایی بستگی دارد." msgid "The memoryview implementation uses atomic operations to track its own exports in the :term:`free-threaded build`. Creating and releasing a memoryview are thread-safe. Attribute access (e.g., :attr:`~memoryview.shape`, :attr:`~memoryview.format`) reads fields that are immutable for the lifetime of the memoryview, so concurrent reads are safe as long as the memoryview has not been released." msgstr "پیادهسازی memoryview از عملیات اتمی برای پیگیری اکسپورتهای خود در :term:`free-threaded build` استفاده میکند. ایجاد و آزادسازی یک memoryview نخایمن (thread-safe) هستند. دسترسی به ویژگیها (برای مثال، :attr:`~memoryview.shape`، :attr:`~memoryview.format`) فیلدهایی را میخواند که در طول عمر memoryview تغییرناپذیر هستند، بنابراین خواندنهای همزمان تا زمانی که memoryview آزاد نشده باشد، ایمن هستند." msgid "However, the actual data accessed through the memoryview is owned by the underlying object. Concurrent access to this data is only safe if the underlying object supports it:" msgstr "با این حال، دادهی واقعی که از طریق memoryview به آن دسترسی دارید، متعلق به شیء زیربنایی است. دسترسی همزمان به این داده تنها در صورتی امن است که شیء زیربنایی از آن پشتیبانی کند:" msgid "For immutable objects like :class:`bytes`, concurrent reads through multiple memoryviews are safe." msgstr "برای اشیاء تغییرناپذیر مانند :class:`bytes`، خواندنهای همزمان از طریق چندین نمای حافظه (memoryview) ایمن هستند." msgid "For mutable objects like :class:`bytearray`, reading and writing the same memory region from multiple threads without external synchronization is not safe and may result in data corruption. Note that even read-only memoryviews of mutable objects do not prevent data races if the underlying object is modified from another thread." msgstr "برای اشیاء تغییرپذیر مانند :class:`bytearray`، خواندن و نوشتن یک ناحیهی حافظهی یکسان توسط چند نخ بدون همگامسازی خارجی ایمن نیست و ممکن است به خرابی داده منجر شود. توجه داشته باشید که حتی memoryviewهای فقطخواندنی از اشیاء تغییرپذیر نیز در صورتی که شیء زیرین توسط نخ دیگری تغییر کند، از رقابتهای دادهای جلوگیری نمیکنند." msgid "" "# NOT safe: concurrent writes to the same buffer\n" "data = bytearray(1000)\n" "view = memoryview(data)\n" "# Thread 1: view[0:500] = b'x' * 500\n" "# Thread 2: view[0:500] = b'y' * 500" msgstr "" "# NOT safe: concurrent writes to the same buffer\n" "data = bytearray(1000)\n" "view = memoryview(data)\n" "# Thread 1: view[0:500] = b'x' * 500\n" "# Thread 2: view[0:500] = b'y' * 500" msgid "" "# Safe: use a lock for concurrent access\n" "import threading\n" "lock = threading.Lock()\n" "data = bytearray(1000)\n" "view = memoryview(data)\n" "\n" "with lock:\n" " view[0:500] = b'x' * 500" msgstr "" "# Safe: use a lock for concurrent access\n" "import threading\n" "lock = threading.Lock()\n" "data = bytearray(1000)\n" "view = memoryview(data)\n" "\n" "with lock:\n" " view[0:500] = b'x' * 500" msgid "Resizing or reallocating the underlying object (such as calling :meth:`bytearray.resize`) while a memoryview is exported raises :exc:`BufferError`. This is enforced regardless of threading." msgstr "تغییر اندازه یا تخصیص مجدد شیء زیرین (مانند فراخوانی :meth:`bytearray.resize`) در حالی که یک memoryview اکسپورت شده باشد، :exc:`BufferError` را پرتاب میکند. این امر صرفنظر از نخبندی اعمال میشود." #~ msgid ":meth:`set.update` and :meth:`set.union` lock both objects only when" #~ msgstr ":meth:`set.update` و :meth:`set.union` هر دو شیء را فقط زمانی قفل میکنند که" #~ msgid "all objects." #~ msgstr "تمام اشیاء." #~ msgid "to lock all objects one-by-one." #~ msgstr "برای قفل کردن همهی اشیاء بهصورت یکییکی." #~ msgid "of type :class:`set`, :class:`frozenset`, or :class:`dict`." #~ msgstr "از نوع :class:`set`، :class:`frozenset` یا :class:`dict`." |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |