@@ -13,7 +13,7 @@ msgid ""
1313msgstr ""
1414"Project-Id-Version : Python 3.9\n "
1515"Report-Msgid-Bugs-To : \n "
16- "POT-Creation-Date : 2020-10-26 04:33 +0000\n "
16+ "POT-Creation-Date : 2020-11-02 04:31 +0000\n "
1717"PO-Revision-Date : 2017-02-16 17:44+0000\n "
1818"
Last-Translator :
m_aciek <[email protected] >, 2020\n "
1919"Language-Team : Polish (https://www.transifex.com/python-doc/teams/5390/pl/)\n "
@@ -391,79 +391,101 @@ msgid ""
391391"placeholder is enough to make it a data descriptor."
392392msgstr ""
393393
394- msgid "Invoking Descriptors "
394+ msgid "Overview of Descriptor Invocation "
395395msgstr ""
396396
397397msgid ""
398- "A descriptor can be called directly by its method name. For example, ``d ."
399- "__get__(obj )``."
398+ "A descriptor can be called directly with ``desc.__get__(obj)`` or ``desc ."
399+ "__get__(None, cls )``."
400400msgstr ""
401401
402402msgid ""
403403"But it is more common for a descriptor to be invoked automatically from "
404- "attribute access. The expression ``obj.d`` looks up ``d`` in the dictionary "
405- "of ``obj``. If ``d`` defines the method :meth:`__get__`, then ``d."
406- "__get__(obj)`` is invoked according to the precedence rules listed below."
404+ "attribute access."
405+ msgstr ""
406+
407+ msgid ""
408+ "The expression ``obj.x`` looks up the attribute ``x`` in the chain of "
409+ "namespaces for ``obj``. If the search finds a descriptor, its :meth:"
410+ "`__get__` method is invoked according to the precedence rules listed below."
407411msgstr ""
408412
409413msgid ""
410414"The details of invocation depend on whether ``obj`` is an object, class, or "
411415"instance of super."
412416msgstr ""
413417
414- msgid "**Objects**: The machinery is in :meth:`object.__getattribute__`. "
418+ msgid "Invocation from an Instance "
415419msgstr ""
416420
417421msgid ""
418- "It transforms ``b.x`` into ``type(b).__dict__['x'].__get__(b, type(b))``."
422+ "Instance lookup scans through a chain of namespaces giving data descriptors "
423+ "the highest priority, followed by instance variables, then non-data "
424+ "descriptors, then class variables, and lastly :meth:`__getattr__` if it is "
425+ "provided."
419426msgstr ""
420427
421428msgid ""
422- "The implementation works through a precedence chain that gives data "
423- "descriptors priority over instance variables, instance variables priority "
424- "over non-data descriptors, and assigns lowest priority to :meth:"
425- "`__getattr__` if provided."
429+ "If a descriptor is found for ``a.x``, then it is invoked with: ``desc."
430+ "__get__(a, type(a))``."
426431msgstr ""
427432
428433msgid ""
429- "The full C implementation can be found in :c:func: "
430- "`PyObject_GenericGetAttr()` in :source:`Objects/object.c`. "
434+ "The logic for a dotted lookup is in :meth:`object.__getattribute__`. Here "
435+ "is a pure Python equivalent:: "
431436msgstr ""
432437
433- msgid "**Classes**: The machinery is in :meth:`type.__getattribute__`."
438+ msgid ""
439+ "The :exc:`TypeError` exception handler is needed because the instance "
440+ "dictionary doesn't exist when its class defines :term:`__slots__`."
434441msgstr ""
435442
436- msgid "It transforms ``A.x`` into ``A.__dict__['x'].__get__(None, A)``. "
443+ msgid "Invocation from a Class "
437444msgstr ""
438445
439446msgid ""
440- "The full C implementation can be found in :c:func:`type_getattro()` in :"
441- "source:`Objects/typeobject.c`."
447+ "The logic for a dotted lookup such as ``A.x`` is in :meth:`type."
448+ "__getattribute__`. The steps are similar to those for :meth:`object."
449+ "__getattribute__` but the instance dictionary lookup is replaced by a search "
450+ "through the class's :term:`method resolution order`."
451+ msgstr ""
452+
453+ msgid "If a descriptor is found, it is invoked with ``desc.__get__(None, A)``."
442454msgstr ""
443455
444456msgid ""
445- "**Super**: The machinery is in the custom :meth:`__getattribute__` method "
446- "for object returned by :class:`super()`."
457+ "The full C implementation can be found in :c:func:`type_getattro()` and :c:"
458+ "func:`_PyType_Lookup()` in :source:`Objects/typeobject.c`."
459+ msgstr ""
460+
461+ msgid "Invocation from Super"
447462msgstr ""
448463
449464msgid ""
450- "The attribute lookup ``super(A, obj).m`` searches ``obj.__class__.__mro__`` "
451- "for the base class ``B`` immediately following ``A`` and then returns ``B."
452- "__dict__['m'].__get__(obj, A)``. If not a descriptor, ``m`` is returned "
453- "unchanged. If not in the dictionary, ``m`` reverts to a search using :meth:"
454- "`object.__getattribute__`."
465+ "The logic for super's dotted lookup is in the :meth:`__getattribute__` "
466+ "method for object returned by :class:`super()`."
455467msgstr ""
456468
457469msgid ""
458- "The implementation details are in :c:func:`super_getattro()` in :source:"
459- "`Objects/typeobject.c`. A pure Python equivalent can be found in `Guido's "
460- "Tutorial`_."
470+ "A dotted lookup such as ``super(A, obj).m`` searches ``obj.__class__."
471+ "__mro__`` for the base class ``B`` immediately following ``A`` and then "
472+ "returns ``B.__dict__['m'].__get__(obj, A)``. If not a descriptor, ``m`` is "
473+ "returned unchanged."
461474msgstr ""
462475
463476msgid ""
464- "**Summary**: The mechanism for descriptors is embedded in the :meth:"
465- "`__getattribute__()` methods for :class:`object`, :class:`type`, and :func:"
466- "`super`."
477+ "The full C implementation can be found in :c:func:`super_getattro()` in :"
478+ "source:`Objects/typeobject.c`. A pure Python equivalent can be found in "
479+ "`Guido's Tutorial <https://www.python.org/download/releases/2.2.3/descrintro/"
480+ "#cooperation>`_."
481+ msgstr ""
482+
483+ msgid "Summary of Invocation Logic"
484+ msgstr ""
485+
486+ msgid ""
487+ "The mechanism for descriptors is embedded in the :meth:`__getattribute__()` "
488+ "methods for :class:`object`, :class:`type`, and :func:`super`."
467489msgstr ""
468490
469491msgid "The important points to remember are:"
@@ -548,9 +570,9 @@ msgstr ""
548570
549571msgid ""
550572"The descriptor protocol is simple and offers exciting possibilities. "
551- "Several use cases are so common that they have been prepackaged into builtin "
552- "tools. Properties, bound methods, static methods, and class methods are all "
553- "based on the descriptor protocol."
573+ "Several use cases are so common that they have been prepackaged into built- "
574+ "in tools. Properties, bound methods, static methods, and class methods are "
575+ "all based on the descriptor protocol."
554576msgstr ""
555577
556578msgid "Properties"
@@ -759,3 +781,70 @@ msgid ""
759781"makes it possible for :func:`classmethod` to support chained decorators. For "
760782"example, a classmethod and property could be chained together::"
761783msgstr ""
784+
785+ msgid "Member Objects"
786+ msgstr ""
787+
788+ msgid ""
789+ "When a class defines ``__slots__``, it replaces instance dictionaries with a "
790+ "fixed-length array of slot values. From a user point of view that has "
791+ "several effects:"
792+ msgstr ""
793+
794+ msgid ""
795+ "1. Provides immediate detection of bugs due to misspelled attribute "
796+ "assignments. Only attribute names specified in ``__slots__`` are allowed::"
797+ msgstr ""
798+
799+ msgid ""
800+ "2. Helps create immutable objects where descriptors manage access to private "
801+ "attributes stored in ``__slots__``::"
802+ msgstr ""
803+
804+ msgid ""
805+ "3. Saves memory. On a 64-bit Linux build, an instance with two attributes "
806+ "takes 48 bytes with ``__slots__`` and 152 bytes without. This `flyweight "
807+ "design pattern <https://en.wikipedia.org/wiki/Flyweight_pattern>`_ likely "
808+ "only matters when a large number of instances are going to be created."
809+ msgstr ""
810+
811+ msgid ""
812+ "4. Blocks tools like :func:`functools.cached_property` which require an "
813+ "instance dictionary to function correctly::"
814+ msgstr ""
815+
816+ msgid ""
817+ "It's not possible to create an exact drop-in pure Python version of "
818+ "``__slots__`` because it requires direct access to C structures and control "
819+ "over object memory allocation. However, we can build a mostly faithful "
820+ "simulation where the actual C structure for slots is emulated by a private "
821+ "``_slotvalues`` list. Reads and writes to that private structure are "
822+ "managed by member descriptors::"
823+ msgstr ""
824+
825+ msgid ""
826+ "The :meth:`type.__new__` method takes care of adding member objects to class "
827+ "variables. The :meth:`object.__new__` method takes care of creating "
828+ "instances that have slots instead of a instance dictionary. Here is a rough "
829+ "equivalent in pure Python::"
830+ msgstr ""
831+
832+ msgid ""
833+ "To use the simulation in a real class, just inherit from :class:`Object` and "
834+ "set the :term:`metaclass` to :class:`Type`::"
835+ msgstr ""
836+
837+ msgid ""
838+ "At this point, the metaclass has loaded member objects for *x* and *y*::"
839+ msgstr ""
840+
841+ msgid ""
842+ "When instances are created, they have a ``slot_values`` list where the "
843+ "attributes are stored::"
844+ msgstr ""
845+
846+ msgid ""
847+ "Unlike the real ``__slots__``, this simulation does have an instance "
848+ "dictionary just to hold the ``_slotvalues`` array. So, unlike the real "
849+ "code, this simulation doesn't block assignments to misspelled attributes::"
850+ msgstr ""
0 commit comments