Use buffer() in Python2 and use memoryview in Python3 #2242

Open
kashikoibumi wants to merge 1 commits from kashikoibumi/memoryview into v0.6
kashikoibumi commented 2024-05-26 06:40:32 +02:00 (Migrated from github.com)

This patch is a Python2-Python3 compatibility issue.

The builtin function buffer() in Python2 is renamed to memoryview() in Python3.
Although memoryview() is also defined in Python2, its behavior has subtle difference, so buffer() can not be simply replaced to memoryview().
Python seems not to be able to pass argument in reference in function parameter, so it is not able to define a function that choose the implementaton of buffer()/memoryview().
So branching by if statement seems to be necessary.

This patch is a Python2-Python3 compatibility issue. The builtin function buffer() in Python2 is renamed to memoryview() in Python3. Although memoryview() is also defined in Python2, its behavior has subtle difference, so buffer() can not be simply replaced to memoryview(). Python seems not to be able to pass argument in reference in function parameter, so it is not able to define a function that choose the implementaton of buffer()/memoryview(). So branching by if statement seems to be necessary.
This repo is archived. You cannot comment on pull requests.
No description provided.