Skip to content

Conversation

@nieksand
Copy link
Contributor

Simplifies the timeout logic.

Avoids two object instantiations for each message sent asynchronously--one for the now() call, one resulting from the datetime arithmetic.

As a nice bonus, time() is also faster than datetime.now(), but I doubt it would be noticeable in the real world:

import datetime
import time

beg_time = time.time()
for _ in xrange(0,4000000):
    datetime.datetime.now()
print 'dt - %.2f sec' % (time.time() - beg_time)

beg_time = time.time()
for _ in xrange(0,4000000):
    time.time()
print 'time - %.2f sec' % (time.time() - beg_time)
dt - 5.72 sec
time - 0.45 sec

@mumrah
Copy link
Collaborator

mumrah commented Dec 28, 2013

@nieksand looks good, thanks for the patch. Also, thanks for including some timings ;)

mumrah added a commit that referenced this pull request Dec 28, 2013
Replace _send_upstream datetime logic with simpler time().
@mumrah mumrah merged commit 8f076df into dpkp:master Dec 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants