C / Python的插座性能? [英] C/Python Socket Performance?

查看:206
本文介绍了C / Python的插座性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题只是涉及C和Python中的插座之间性能上的差异。由于我的Python版本是CPython的,我以为这是类似的,但我很好奇,如果有人居然有真实的基准,或至少是一个基于证据的意见。

my question simply relates to the difference in performance between a socket in C and in Python. Since my Python build is CPython, I assume it's similar, but I'm curious if someone actually has "real" benchmarks, or at least an opinion that's evidence based.

我的逻辑是这样:


  • 交流电插座更快?然后写一个C
    延期。

  • 没有/几乎没有区别吗?
    继续写在Python,并找出
    如何获取数据包级别控制
    (Scapy的?dpkt?)

我敢肯定,有人会想知道这两种上下文或好奇。我计划建立一种代理为自己(不适用于互联网浏览,匿名等),将我想用它使用特定端口的应用程序绑定。然后,在所有的数据包的端口表示将进行排队,地址头修改,然后发送,等等等等。

I'm sure someone will want to know for either context or curiosity. I plan to build a sort of proxy for myself (not for internet browsing, anonymity, etc) and will bind the application I want to use with it to a specific port. Then, all packets on said port will be queued, address header modified, and then sent, etc, etc.

先谢谢了。

推荐答案

在一般情况下,在Python插座执行就好了。例如,BitTorrent的追踪服务器的参考实现用Python编写的。

In general, sockets in Python perform just fine. For example, the reference implementation of the BitTorrent tracker server is written in Python.

当操作的网络操作中,网络的速度通常是限制因素。也就是说,在C和Python的插座code之间的高速任何可能的微小差异完全是由事实所掩盖,你正在做的联网某种

When doing networking operations, the speed of the network is usually the limiting factor. That is, any possible tiny difference in speed between C and Python's socket code is completely overshadowed by the fact that you're doing networking of some kind.

不过,你对你想要做什么的描述表明,要检查和修改单个IP的分组的。这超出了Python的标准网络库的能力,在任何情况下,一个非常依赖于操作系统的操作。而不是问哪个更快?你需要先问这可能吗?

However, your description of what you want to do indicates that you want to inspect and modify individual IP packets. This is beyond the capabilities of Python's standard networking libraries, and is in any case a very OS-dependent operation. Rather than asking "which is faster?" you will need to first ask "is this possible?"

这篇关于C / Python的插座性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆