terminology question - "foreign function library"

M

mirandacascade

I am prompted to make these inquiries after seeing the following link
to ctypes:

http://docs.python.org/lib/module-ctypes.html

in which ctypes is described as a foreign function library.

What is the definition of "foreign function library"?
Is the concept different from a "package"?
Is the concept different from a "module"?

Thank you.
 
T

Terry Reedy

|I am prompted to make these inquiries after seeing the following link
| to ctypes:
|
| http://docs.python.org/lib/module-ctypes.html
|
| in which ctypes is described as a foreign function library.
|
| What is the definition of "foreign function library"?

A library for connecting to and making use of foreign functions,
which are functions written in a foreign (to Python) language
and usually not particularly designed with Python in mind.

| Is the concept different from a "package"?
| Is the concept different from a "module"?

Ctypes is one particular module with the particular purpose given.
A module in general can be for any purpose.

Terry Jan Reedy
 
G

Gary Herron

I am prompted to make these inquiries after seeing the following link
to ctypes:

http://docs.python.org/lib/module-ctypes.html

in which ctypes is described as a foreign function library.

What is the definition of "foreign function library"?
Is the concept different from a "package"?
Is the concept different from a "module"?
Neither. If you have a library, completely unrelated to Python, but you
would like to make calls into it from Python, there are several ways to
proceed.

(A good example of such a library is the OpenGL library:
C:/WINDOWS/SYSTEM32/opengl32.dll.)

You can craft an extension to Python, written in C perhaps and linked to
the DLL in question, that provides functions which can be called from
Python and which make the appropriate calls into the DLL. (Several
products help with building of such an extension module, SWIG being the
one I've used.)

A newer alternative to building such extensions is ctypes. If you can
discern (from the documentation) the exact calling parameters footprint
to a function in a DLL, then ctypes can directly call that function with
your parameters. This is done directly in Python and ctypes without the
need for building any extension module.

Gary Herron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top