python re模块安装_关于 Python re 模块和 google re2 模块

测试代码:

from datetime import date

import tornado.escape

import tornado.ioloop

import tornado.web

class VersionHandler(tornado.web.RequestHandler):

def get(self):

response = { 'version': '3.5.1',

'last_build': date.today().isoformat() }

self.write(response)

class GetGameByIdHandler(tornado.web.RequestHandler):

def get(self, id):

response = { 'id': int(id),

'name': 'Crazy Game',

'release_date': date.today().isoformat() }

self.write(response)

application = tornado.web.Application([

(r"/getgamebyid/([0-9]+)", GetGameByIdHandler),

(r"/version", VersionHandler)

])

if name == "main":

application.listen(8888)

tornado.ioloop.IOLoop.instance().start()

python-re:

[[email protected] ~]$ webbench -c 1000 -t 60 -2 --get http://192.168.1.108:8888/getgamebyid/1

Webbench - Simple Web Benchmark 1.5

Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.

Benchmarking: GET http://192.168.1.108:8888/getgamebyid/1 (using HTTP/1.1)

1000 clients, running 60 sec.

Speed=80840 pages/min, 349074 bytes/sec.

Requests: 80247 susceed, 593 failed.

python-re2

Benchmarking: GET http://192.168.1.108:8888/getgamebyid/1 (using HTTP/1.1)

1000 clients, running 60 sec.

Speed=81921 pages/min, 0 bytes/sec.

Requests: 81430 susceed, 491 failed.

看起来能得得到小幅度的性能提升,但是 RE2 没有 groupindex 这个对象,会报错,估计得分析一下 pythgon-re2 的源码源码:

File "/usr/lib64/python2.7/site-packages/tornado/web.py", line 1994, in _find_handler

if spec.regex.groupindex:

AttributeError: 're2.Pattern' object has no attribute 'groupindex'

继续挖坑

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值