Skip to content

Instantly share code, notes, and snippets.

@kevinkindom
kevinkindom / Python Socket 编程详细介绍.md
Last active May 8, 2024 02:47
Python Socket 编程详细介绍

Python Socket 编程详细介绍

Python 提供了两个基本的 socket 模块:

  • Socket 它提供了标准的BSD Socket API。
  • SocketServer 它提供了服务器重心,可以简化网络服务器的开发。

下面讲解下 Socket模块功能。

Socket 类型

@donatello
donatello / client.py
Last active June 7, 2018 13:38
Gevent + Request Session object Thread Safety Test
import gevent
from gevent.monkey import patch_all
patch_all()
import requests
import json
s = requests.Session()
def make_request(s, d):
@justinfx
justinfx / enc_dec_test.py
Last active October 16, 2022 13:28
Speed test of common serializers on python 2.7.2 (pickle, cPickle, ujson, cjson, simplejson, json, yajl, msgpack)
"""
Dependencies:
pip install tabulate simplejson ujson yajl msgpack
"""
from timeit import timeit
from tabulate import tabulate
setup = '''d = {
'words': """
@kesor
kesor / profile_middleware.py
Last active March 16, 2021 15:37
Django cProfile middleware
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
import cProfile
import pstats
import marshal
from cStringIO import StringIO
class ProfileMiddleware(object):
def __init__(self):
if not settings.DEBUG: