Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
44adb0c9
Kaydet (Commit)
44adb0c9
authored
Nis 11, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added note about SWIG (replacing a whole lot of nonsense about how
difficult it is to do).
üst
cb5cf9b1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
27 deletions
+10
-27
FAQ
Misc/FAQ
+10
-27
No files found.
Misc/FAQ
Dosyayı görüntüle @
44adb0c9
...
...
@@ -1866,33 +1866,16 @@ Calling setattr(), to assign to variables in the module, also works.
5.10. Q. How do I interface to C++ objects from Python?
A. Depending on your requirements, there are many approaches. Begin
by reading the "Extending and Embedding" document (Doc/ext.tex, see
also <URL:http://www.python.org/doc/>). Realize that for the Python
run-time system, there isn't a whole lot of difference between C and
C++ -- so the strategy to build a new Python type around a C structure
(pointer) type will also work for C++ objects.
Automatic generation of interfaces between Python and C++ is still at
the horizon -- parsing C++ header files requires an almost complete
C++ parser, and many features aren't easily translated from C++ to
Python: certain forms of operator oveloading, function overloading
(best approached by a varargs function which explicitly type-checks
its arguments), and reference arguments are just a number of features
that are hard to translate correctly if at all.
The hardest problem is to transparently translate the C++ class
hierarchy to Python, so that Python programs derive classes from C++
classes. Given suitable constraints, this may be possible, but it
would require more space than I have in this FAQ to explain how.
In any case, you can get quite a bit done without this, using just the
existing classes from Python.
If this all seems rather daunting, that may be because it is -- C++
isn't exactly a baby to handle without gloves! However, people have
accomplished amazing feats of interfacing between Python and C++, and
a detailed question posted to the Python list is likely to elicit some
interesting and useful responses.
A. Depending on your requirements, there are many approaches. To do
this manually, begin by reading the "Extending and Embedding" document
(Doc/ext.tex, see also <URL:http://www.python.org/doc/>). Realize
that for the Python run-time system, there isn't a whole lot of
difference between C and C++ -- so the strategy to build a new Python
type around a C structure (pointer) type will also work for C++
objects.
A useful automated approach (which also works for C) is SWIG:
http://www.cs.utah.edu/~beazley/SWIG/.
6. Python's design
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment