Skip to content
View aprknight's full-sized avatar
  • UK
Block or Report

Block or report aprknight

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
aprknight/README.md

from timeit import timeit

coordinates = ('S', 'W', 'W', 'S', 'E', 'S', 'E', 'N', 'N')

def func1(): # simplistic single pass sn = [] ew = []

for c in coordinates:
    if c in 'SN':
        sn.append(c)
    else:
        ew.append(c)

return tuple(sn), tuple(ew)

def func2(): # tuple NS = ('N','S') EW = ('E','W') sn = [s for s in coordinates if s in NS] ew = [s for s in coordinates if s in EW] return tuple(sn), tuple(ew)

def func3(): # string NS = 'NS' EW = 'EW' sn = [s for s in coordinates if s in NS] ew = [s for s in coordinates if s in EW] return tuple(sn), tuple(ew)

def func4(): # set NS = {'N','S'} EW = {'E','W'} sn = [s for s in coordinates if s in NS] ew = [s for s in coordinates if s in EW] return tuple(sn), tuple(ew)

def func5(): # list NS = ['N','S'] EW = ['E','W'] sn = [s for s in coordinates if s in NS] ew = [s for s in coordinates if s in EW] return tuple(sn), tuple(ew)

for func in func1, func2, func3, func4, func5: print(func.name, timeit(lambda:func()))

Popular repositories Loading

  1. ateamfun ateamfun Public

    Forked from ekham/ateamfun

    Java

  2. aprknight aprknight Public

    Config files for my GitHub profile.

  3. pyshp pyshp Public

    Forked from GeospatialPython/pyshp

    This library reads and writes ESRI Shapefiles in pure Python.

    Python

  4. ccn ccn Public

    Python code for validating credit card numbers

    Python