[pypy-commit] pypy default: speed up datetime fromtimestamp (this check costs time)
bdkearns
noreply at buildbot.pypy.org
Tue Nov 24 15:43:55 EST 2015
Author: Brian Kearns <bdkearns at gmail.com>
Branch:
Changeset: r80911:6577bbdc8e76
Date: 2015-11-24 15:43 -0500
http://bitbucket.org/pypy/pypy/changeset/6577bbdc8e76/
Log: speed up datetime fromtimestamp (this check costs time)
diff --git a/lib_pypy/datetime.py b/lib_pypy/datetime.py
--- a/lib_pypy/datetime.py
+++ b/lib_pypy/datetime.py
@@ -17,7 +17,6 @@
"""
from __future__ import division
-import numbers as _numbers
import time as _time
import math as _math
import struct as _struct
@@ -1484,13 +1483,10 @@
@classmethod
def _from_timestamp(cls, converter, timestamp, tzinfo):
- if isinstance(timestamp, _numbers.Integral):
- us = 0
- else:
- t_full = timestamp
- timestamp = int(_math.floor(timestamp))
- frac = t_full - timestamp
- us = _round(frac * 1e6)
+ t_full = timestamp
+ timestamp = int(_math.floor(timestamp))
+ frac = t_full - timestamp
+ us = _round(frac * 1e6)
# If timestamp is less than one microsecond smaller than a
# full second, us can be rounded up to 1000000. In this case,
More information about the pypy-commit
mailing list