Pelokalan
Python ID
id en
Masuk
Proyek
c-api__allocation.po Berkas proyek · python-docs-id-3.14 · Bahasa Indonesia
Modul PO Hanya lihat
Teks sumber — English
Terjemahan — Bahasa Indonesia
Allocating objects on the heap
Initialize a newly allocated object *op* with its type and initial reference. Returns the initialized object. Other fields of the object are not initialized. Despite its name, this function is unrelated to the object's :meth:`~object.__init__` method (:c:member:`~PyTypeObject.tp_init` slot). Specifically, this function does **not** call the object's :meth:`!__init__` method.
Menginisialisasi objek *op* yang baru dialokasikan dengan tipe dan referensi awalnya. Mengembalikan objek yang telah diinisialisasi. Bidang lain dari objek tidak diinisialisasi. Terlepas dari namanya, fungsi ini tidak terkait dengan metode :meth:`~object.__init__` objek (slot:c:member:`~PyTypeObject.tp_init` ). Secara khusus, fungsi ini tidak **tidak** memanggil metode :meth:`!__init__` objek.
In general, consider this function to be a low-level routine. Use :c:member:`~PyTypeObject.tp_alloc` where possible. For implementing :c:member:`!tp_alloc` for your type, prefer :c:func:`PyType_GenericAlloc` or :c:func:`PyObject_New`.
Secara umum, anggaplah fungsi ini sebagai rutinitas tingkat rendah. Gunakan :c:member:`~PyTypeObject.tp_alloc` jika memungkinkan. Untuk mengimplementasikan :c:member:`!tp_alloc` untuk tipe Anda, pilih :c:func:`PyType_GenericAlloc` atau :c:func:`PyObject_New`.
This function only initializes the object's memory corresponding to the initial :c:type:`PyObject` structure. It does not zero the rest.
Fungsi ini hanya menginisialisasi memori objek yang sesuai dengan struktur awal :c:type:`PyObject`. Fungsi ini tidak mengosongkan sisanya.
This does everything :c:func:`PyObject_Init` does, and also initializes the length information for a variable-size object.
Ini melakukan segalanya :c:func:`PyObject_Init`, dan juga menginisialiasi panjang informasi pada sebuah ukuran object variabel.
This function only initializes some of the object's memory. It does not zero the rest.
Fungsi ini hanya menginisialisasi sebagian memori objek. Fungsi ini tidak mengosongkan sisanya.
Allocates a new Python object using the C structure type *TYPE* and the Python type object *typeobj* (``PyTypeObject*``) by calling :c:func:`PyObject_Malloc` to allocate memory and initializing it like :c:func:`PyObject_Init`. The caller will own the only reference to the object (i.e. its reference count will be one).
Mengalokasikan objek Python baru menggunakan tipe struktur C *TYPE* dan objek tipe Python *typeobj* (``PyTypeObject*``) dengan memanggil :c:func:`PyObject_Malloc` untuk mengalokasikan memori dan menginisialisasinya sebagai :c:func:`PyObject_Init`. Pemanggil akan memiliki satu-satunya referensi ke objek tersebut (misal: jumlah referensinya adalah satu).
Avoid calling this directly to allocate memory for an object; call the type's :c:member:`~PyTypeObject.tp_alloc` slot instead.
Hindari memanggil ini secara langsung untuk mengalokasikan memori untuk sebuah objek; panggil slot :c:member:`~PyTypeObject.tp_alloc` dari tipe sebagai gantinya.
When populating a type's :c:member:`~PyTypeObject.tp_alloc` slot, :c:func:`PyType_GenericAlloc` is preferred over a custom function that simply calls this macro.
Ketika mengisi slot tipe :c:member:`~PyTypeObject.tp_alloc` , :c:func:`PyType_GenericAlloc` lebih direkomendasikan daripada fungsi kustom yang hanya memanggil makro ini.
This macro does not call :c:member:`~PyTypeObject.tp_alloc`, :c:member:`~PyTypeObject.tp_new` (:meth:`~object.__new__`), or :c:member:`~PyTypeObject.tp_init` (:meth:`~object.__init__`).
Makro ini tidak memanggil :c:member:`~PyTypeObject.tp_alloc`, :c:member:`~PyTypeObject.tp_new` (:meth:`~object.__new__`), atau :c:member:`~PyTypeObject.tp_init` (:meth:`~object.__init__`).
This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in :c:member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_New` instead.
Ini tidak dapat digunakan untuk objek dengan :c:macro:`Py_TPFLAGS_HAVE_GC` yang diatur di :c:member:`~PyTypeObject.tp_flags`; gunakan :c:macro:`PyObject_GC_New` sebagai gantinya.
Memory allocated by this macro must be freed with :c:func:`PyObject_Free` (usually called via the object's :c:member:`~PyTypeObject.tp_free` slot).
Memori yang dialokasikan oleh makro ini harus dibebaskan dengan :c:func:`PyObject_Free` (biasanya dipanggil melalui slot objek :c:member:`~PyTypeObject.tp_free` ).
This macro does not construct a fully initialized object of the given type; it merely allocates memory and prepares it for further initialization by :c:member:`~PyTypeObject.tp_init`. To construct a fully initialized object, call *typeobj* instead. For example::
Makro ini tidak membuat objek yang diinisialisasi penuh dari tipe yang diberikan; makro ini hanya mengalokasikan memori dan mempersiapkannya untuk inisialisasi lebih lanjut oleh :c:member:`~PyTypeObject.tp_init`. Untuk membuat objek yang diinisialisasi secara penuh, panggil *typeobj* sebagai gantinya. Sebagai contoh::
PyObject *foo = PyObject_CallNoArgs((PyObject *)&PyFoo_Type);
PyObject * foo = PyObject_CallNoArgs((PyObject *) & PyFoo_Type);
:c:func:`PyObject_Free`
:c:func:`PyObject_Free`
:c:macro:`PyObject_GC_New`
:c:macro:`PyObject_GC_New`
:c:member:`~PyTypeObject.tp_alloc`
:c:member:`~PyTypeObject.tp_alloc`
Like :c:macro:`PyObject_New` except:
Seperti :c:macro:`PyObject_New` kecuali:
It allocates enough memory for the *TYPE* structure plus *size* (``Py_ssize_t``) fields of the size given by the :c:member:`~PyTypeObject.tp_itemsize` field of *typeobj*.
Ini mengalokasikan cukup memori untuk struktur *TYPE* ditambah bidang *size* (``Py_ssize_t``) dengan ukuran yang diberikan oleh bidang :c:member:`~PyTypeObject.tp_itemsize` dari *typeobj*.
The memory is initialized like :c:func:`PyObject_InitVar`.
Memori diinisialisasi seperti :c:func:`PyObject_InitVar`.
This is useful for implementing objects like tuples, which are able to determine their size at construction time. Embedding the array of fields into the same allocation decreases the number of allocations, improving the memory management efficiency.
Hal ini berguna untuk mengimplementasikan objek seperti tuple, yang dapat menentukan ukurannya pada saat konstruksi. Menanamkan array of fields ke dalam alokasi yang sama akan mengurangi jumlah alokasi, sehingga meningkatkan efisiensi manajemen memori.
This cannot be used for objects with :c:macro:`Py_TPFLAGS_HAVE_GC` set in :c:member:`~PyTypeObject.tp_flags`; use :c:macro:`PyObject_GC_NewVar` instead.
Ini tidak dapat digunakan untuk objek dengan :c:macro:`Py_TPFLAGS_HAVE_GC` yang diatur di :c:member:`~PyTypeObject.tp_flags`; gunakan :c:macro:`PyObject_GC_NewVar` sebagai gantinya.
Memory allocated by this function must be freed with :c:func:`PyObject_Free` (usually called via the object's :c:member:`~PyTypeObject.tp_free` slot).
Memori yang dialokasikan oleh fungsi ini harus dibebaskan dengan :c:func:`PyObject_Free` (biasanya dipanggil melalui slot :c:member:`~PyTypeObject.tp_free` objek).
PyObject *list_instance = PyObject_CallNoArgs((PyObject *)&PyList_Type);
PyObject * list_instance = PyObject_CallNoArgs((PyObject *) & PyList_Type);
:c:macro:`PyObject_GC_NewVar`
:c:macro:`PyObject_GC_NewVar`
Object which is visible in Python as ``None``. This should only be accessed using the :c:macro:`Py_None` macro, which evaluates to a pointer to this object.
Object yang terlihat di Python sebagai ``None``. Ini seharusnya hanya dapat diakses menggunakan makro :c:macro:`Py_None`, yang mengevaluasi ke sebuah pointer ke object ini.
:ref:`moduleobjects`
:ref:`moduleobjects`
:c:macro:`PyObject_New`
:c:macro:`PyObject_New`
:c:macro:`PyObject_NewVar`
:c:macro:`PyObject_NewVar`
:c:func:`PyObject_Init`
:c:func:`PyObject_InitVar`
:c:func:`PyObject_Malloc`
:c:func:`PyObject_Malloc`
:c:func:`PyObject_Realloc`
:c:func:`PyObject_Realloc`