小编oi_*_*_io的帖子

为什么asyncio库比这个I/O绑定操作的线程慢?

我正在编写一个用于枚举网站域名的python程序.例如,'a.google.com'.

首先,我使用该threading模块执行此操作:

import string
import time
import socket
import threading
from threading import Thread
from queue import Queue

'''
enumerate a site's domain name like this:
1-9 a-z + .google.com
1.google.com
2.google.com
.
.
1a.google.com
.
.
zz.google.com

'''

start = time.time()
def create_host(char):
    '''
    if char is '1-9a-z'
    create char like'1,2,3,...,zz'
    '''
    for i in char:
        yield i
    for i in create_host(char):
        if len(i)>1:
            return False
        for c in char:
            yield c + i


char = string.digits …
Run Code Online (Sandbox Code Playgroud)

python python-3.x python-asyncio

19
推荐指数
1
解决办法
7275
查看次数

标签 统计

python ×1

python-3.x ×1

python-asyncio ×1