Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Speed tests with a Stream?

Aperta
#419 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python

Direzione di ricerca

Start by running the two standalone benchmark scripts, comparing the generator loop with Stream.from_iterable() and sink_to_list(). Check the streamz documentation and implementation of source.start() and sink_to_list() to determine whether the polling loop is required. Done means documenting the expected performance and the correct standalone-script usage, or identifying a reproducible defect.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I am trying to compare the speed of operation when a Stream is introduced into the code. These are both scripts that need to be run.

A 'plain' Python example:

from timeit import default_timer as timer
LIMIT = 100000

def sequencer(limit=LIMIT):
    num = 0
    while num < limit:
        yield num
        num += 1

L = []
start = timer()
for i in sequencer():
   L.append(i)

end = timer()
print(end - start)

This takes about 17 milliseconds to run.

An attempt to replicate the above with streamz:

from timeit import default_timer as timer
from streamz import Stream
LIMIT = 100000

def sequencer(limit=LIMIT):
    num = 0
    while num < limit:
        yield num
        num += 1

source = Stream.from_iterable(sequencer())
L = source.sink_to_list()

start = timer()
source.start()
while True:
    if len(L) >= LIMIT:
        break

end = timer()
print(end - start)

This takes about 1200 milliseconds to run. Is this the expected slowdown (two orders-of-magnitude)?

I am not sure though if the streamz code is correct? Its based off of the examples in the docs, but those examples all seem geared towards use in the shell rather than in standalone scripts. If you omit the while True: section, then no data ends up in the output list?

Lingua principale
Python
Stelle
1.3k
Fork
149
Merge medio
17h 39m
PR unite (30g)
1

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-streamz/streamz

Tutte le issue di python-streamz/streamz

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.