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
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`.
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__`).
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:`PyType_GenericAlloc`
:c:func:`PyType_GenericAlloc`
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);