binary using both Python C API version 2 and 3

rwst

In an open source project1 we have Python/Cython and C/C++ modules mixed with one C++ library using the Python C API. The API changed only a few function's names from 2 to 3. Assume the library is written without those functions. Will it link to Python3 if compiled with Python2, and vice versa? Is this prevented by macros in the API headers?

Having a library binary that may link to both would spare us major packaging hassles.

Antti Haapala

No, it wouldn't work. Don't try it.

Binary modules are not guaranteed to be binary-portable even say from 3.5 to 3.6. If you're lucky, then there is some mechanism that will prohibit you from doing this insanity. If however you manage to link the library somehow, there will be some subtle differences that will cause serious bugs, such as the layout of PyObject changing and so forth.

The Python interface must be recompiled for the exact Python version. Source compatibility between Python 2 and 3 is a different thing and is relatively easy to achieve.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is there a way to create a python module using SWIG C++ which can be imported in both Python2 and Python3

From Dev

print in python using python3 without python2 and python1 or both at the same time?

From Dev

How to do markererclusterer in android using both map apiv2 or map api v3

From Java

Using both Python 2.x and Python 3.x in IPython Notebook

From Dev

Import structure that works both in packages and out, in both Python 2 and 3?

From Dev

String to bytes in both Python 2 and 3

From Dev

How to overwrite in both python 2 and 3?

From Dev

Can I deploy both python 2 and 3 django app with apache using mod_wsgi?

From Dev

Using strings and byte-like objects compatibly in code to run in both Python 2 & 3

From Dev

Create a virtualenv with both python2 and python3

From Dev

How to judge a file type both work in python 2 and python 3

From Dev

Multiple Web API 2 apps in one solution, both using Ninject

From Dev

How to migrate the code using Six Module that will be compatible in python2 and python3 version

From Dev

Compare string to bytes that works in both Python 2 and 3

From Dev

Using C API of tesseract 3.02 with ctypes and cv2 in python

From Dev

Using C API of tesseract 3.02 with ctypes and cv2 in python

From Dev

Supporting types in unified python 2/3 version

From Dev

How to detect Python Version 2 or 3 in script?

From Dev

binary conversion using 3 figures system 0,1,2

From Dev

How to share my youtube-playlist with the end user, using You Tube data api version 3 objective c

From Dev

using `bytes` in python 2 and 3

From Dev

How to wrap a C++ object using pure Python Extension API (python3)?

From Dev

how to post data and binary data using urllib2 in python

From Dev

how to post data and binary data using urllib2 in python

From Dev

Convert Python binary data to R using rpy2

From Dev

Difference between return from Python 2 --version check and Python 3

From Dev

Specifying a script is Python 2 or 3 which version of Python a program is written for

From Dev

Reading binary data written using Python struct in C

From Dev

WordPress - Reply on comments with rest API using version 2

Related Related

  1. 1

    Is there a way to create a python module using SWIG C++ which can be imported in both Python2 and Python3

  2. 2

    print in python using python3 without python2 and python1 or both at the same time?

  3. 3

    How to do markererclusterer in android using both map apiv2 or map api v3

  4. 4

    Using both Python 2.x and Python 3.x in IPython Notebook

  5. 5

    Import structure that works both in packages and out, in both Python 2 and 3?

  6. 6

    String to bytes in both Python 2 and 3

  7. 7

    How to overwrite in both python 2 and 3?

  8. 8

    Can I deploy both python 2 and 3 django app with apache using mod_wsgi?

  9. 9

    Using strings and byte-like objects compatibly in code to run in both Python 2 & 3

  10. 10

    Create a virtualenv with both python2 and python3

  11. 11

    How to judge a file type both work in python 2 and python 3

  12. 12

    Multiple Web API 2 apps in one solution, both using Ninject

  13. 13

    How to migrate the code using Six Module that will be compatible in python2 and python3 version

  14. 14

    Compare string to bytes that works in both Python 2 and 3

  15. 15

    Using C API of tesseract 3.02 with ctypes and cv2 in python

  16. 16

    Using C API of tesseract 3.02 with ctypes and cv2 in python

  17. 17

    Supporting types in unified python 2/3 version

  18. 18

    How to detect Python Version 2 or 3 in script?

  19. 19

    binary conversion using 3 figures system 0,1,2

  20. 20

    How to share my youtube-playlist with the end user, using You Tube data api version 3 objective c

  21. 21

    using `bytes` in python 2 and 3

  22. 22

    How to wrap a C++ object using pure Python Extension API (python3)?

  23. 23

    how to post data and binary data using urllib2 in python

  24. 24

    how to post data and binary data using urllib2 in python

  25. 25

    Convert Python binary data to R using rpy2

  26. 26

    Difference between return from Python 2 --version check and Python 3

  27. 27

    Specifying a script is Python 2 or 3 which version of Python a program is written for

  28. 28

    Reading binary data written using Python struct in C

  29. 29

    WordPress - Reply on comments with rest API using version 2

HotTag

Archive