Skip to content

A fast, reckless strptime implementation for Python

Notifications You must be signed in to change notification settings

danudey/pystrptime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

pystrptime

A really, really dumb strptime "implementation" for Python.

What doesn't it do?

Basically it takes a format like 2012-02-02 12:23:49 and turns it into datetime.datetime(2012, 2, 2, 12, 23, 49). There's no timezones, no daylight savings, no anything. Just go from a string to a datetime that matches the numbers in that string or raise a ValueError if it doesn't.

Stupid benchmarks

For a list of 256,806 matching strings:

In [3]: %%timeit
   ...: for line in dates:
   ...:     dt = datetime.datetime.strptime(line, form)
   ...:
1 loop, best of 3: 4.43 s per loop

In [2]: %%timeit
   ...: for line in dates:
   ...:     dt = strptime.strptime(line, form)
   ...:
10 loops, best of 3: 95.8 ms per loop

This is a 47x improvement over the datetime module itself.

About

A fast, reckless strptime implementation for Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published