[简体中文](README-CN.md)
# phpy
A library for inter-calling `Python` and `PHP`.
You can use Python functions and libraries in PHP, or use PHP packages in Python.
> See documents: [docs/en/README.md](docs/en/README.md)
> Supports Linux/Windows/macOS
> Not support Python multithreading or async-io features
## py2php
[py2php](https://swoole.com/py2php/) is online utility that will auto-translate python code into PHP code.
## Calling Python from PHP
Compile and install phpy.so as an extension, and append `extension=phpy.so` to `php.ini`.
### PHP Example:
```php
$os = PyCore::import("os");
echo $os->uname();
```
## Calling PHP from Python
Simply import it as a C++ Mudule.
### Python Example:
```python
import phpy
content = phpy.call('file_get_contents', 'test.txt')
o = phpy.Object('redis')
assert o.call('connect', '127.0.0.1', 6379)
rdata = phpy.call('uniqid')
assert o.call('set', 'key', rdata)
assert o.call('get', 'key') == rdata
```
## Implementation
It creates `ZendVM` and `CPython VM` in the process at the same time, and directly uses C functions to call each other in the process stack space.
The overhead is only the conversion of `zval <-> PyObject` structures, so the performance is very high.
In the benchmark test, we created a `PyDict` and executed PHP code and Python code to read and write 10 million times respectively.
The performance of phpy writing `PyDict` with PHP code is `14%` higher than the native Python, and the read performance is `25%` higher.
> More details: [docs/en/benchmark.md](docs/en/benchmark.md)
没有合适的资源?快使用搜索试试~ 我知道了~
连接 python 与 PHP 生态.zip
共275个文件
php:98个
py:76个
md:43个
需积分: 5 0 下载量 59 浏览量
2024-11-02
18:30:02
上传
评论
收藏 378KB ZIP 举报
温馨提示
连接 python 与 PHP 生态.zip
资源推荐
资源详情
资源评论
收起资源包目录
连接 python 与 PHP 生态.zip (275个子文件)
Dockerfile.alpine 714B
class.c 4KB
core.cc 15KB
core.cc 12KB
object.cc 10KB
array.cc 9KB
object.cc 8KB
string.cc 8KB
module.cc 7KB
class.cc 5KB
dict.cc 4KB
callable.cc 4KB
list.cc 4KB
reference.cc 4KB
tuple.cc 3KB
error.cc 3KB
resource.cc 3KB
set.cc 2KB
str.cc 2KB
sequence.cc 2KB
fn.cc 2KB
iter.cc 2KB
type.cc 2KB
module.cc 2KB
phpy.cc 2KB
.clang-format 3KB
log.csv 329B
Dockerfile 484B
test.glade 780B
phpy.h 12KB
phpy_object_arginfo.h 4KB
phpy_core_arginfo.h 3KB
version.tpl.h 2KB
phpy_dict_arginfo.h 2KB
phpy_list_arginfo.h 2KB
phpy_tuple_arginfo.h 2KB
phpy_set_arginfo.h 918B
phpy_sequence_arginfo.h 772B
phpy_str_arginfo.h 440B
phpy_fn_arginfo.h 435B
phpy_iter_arginfo.h 403B
phpy_type_arginfo.h 403B
php_phpy.h 300B
phpy_module_arginfo.h 202B
phpy_error_arginfo.h 201B
composer.json 821B
config.m4 2KB
core.md 4KB
core.md 3KB
build-on-windows.md 3KB
benchmark.md 3KB
benchmark.md 3KB
object.md 2KB
build.md 2KB
object.md 2KB
build.md 2KB
fn.md 2KB
module.md 2KB
socket.md 2KB
memory.md 2KB
README.md 2KB
README-CN.md 1KB
memory.md 1KB
module.md 1KB
build.md 1KB
README.md 1KB
fn.md 1KB
tutorial.md 1KB
string.md 1KB
tutorial.md 1KB
function.md 974B
tutorial.md 914B
exception.md 905B
function.md 875B
tutorial.md 854B
composer.md 831B
int.md 815B
composer.md 783B
exception.md 764B
int.md 736B
roadmap.md 730B
array.md 699B
README.md 685B
roadmap.md 647B
object.md 461B
object.md 399B
reference.md 337B
reference.md 296B
class.md 292B
class.md 277B
pyplot.php 17KB
os.php 16KB
torch.php 16KB
Generator.php 8KB
sys.php 8KB
ast.php 7KB
tkinter.php 6KB
bootstrap.php 5KB
CoreTest.php 4KB
pickle.php 4KB
共 275 条
- 1
- 2
- 3
资源评论
YOLO数据集工作室
- 粉丝: 752
- 资源: 1609
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- AI数据集生成20231221
- 手机电池用PCM焊接机sw18可编辑全套技术资料100%好用.zip
- 双工位贴易撕贴胶纸设备sw18全套技术资料100%好用.zip
- 手机锂电池长宽厚尺寸测量设备sw18可编辑全套技术资料100%好用.zip
- 手机主板插拔耐压测试sw17可编辑全套技术资料100%好用.zip
- 糖果生产输送线sw18全套技术资料100%好用.zip
- 铜线切断机sw18可编辑全套技术资料100%好用.zip
- 双工位自动浇筑机(含DFM)sw18可编辑全套技术资料100%好用.zip
- 凸轮(ppu)机械手全套技术资料100%好用.zip
- shacesrric0101.zip
- 梁烨炜网页期末作业.zip
- 桶提手成型组装设备sw20可编辑全套技术资料100%好用.zip
- 微型断路器保险丝组装设备(含DFM)sw17可编辑全套技术资料100%好用.zip
- 物料储存机sw18可编辑全套技术资料100%好用.zip
- usb开发资料linux
- 机器学习中决策树练习数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功