Last active
December 2, 2024 17:06
-
-
Save jGaboardi/754e878ee4cac986132295ed43e74512 to your computer and use it in GitHub Desktop.
vectorized_linestring_explode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.12.7"},"gist_info":{"create_date":"2024-12-02T02:01:18Z","gist_id":"754e878ee4cac986132295ed43e74512","gist_url":"https://gist.github.com/jGaboardi/754e878ee4cac986132295ed43e74512"}},"nbformat_minor":5,"nbformat":4,"cells":[{"id":"879bb7f2-9ccf-4845-b261-fc9cc1c8b2cc","cell_type":"markdown","source":"# Vectorized – Explode LineStrings into constituent pairwise segments\n\n1. Functions\n2. Small Example\n3. Medium Example\n4. Large Example\n5. Huge Example","metadata":{}},{"id":"b152cfaa-512f-47b0-bdac-6e1314bbcdac","cell_type":"code","source":"%load_ext watermark\n%watermark","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:03:51.059577Z","iopub.execute_input":"2024-12-02T17:03:51.059757Z","iopub.status.idle":"2024-12-02T17:03:51.087122Z","shell.execute_reply.started":"2024-12-02T17:03:51.059736Z","shell.execute_reply":"2024-12-02T17:03:51.086828Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"Last updated: 2024-12-02T12:03:51.075912-05:00\n\nPython implementation: CPython\nPython version : 3.12.7\nIPython version : 8.30.0\n\nCompiler : Clang 17.0.6 \nOS : Darwin\nRelease : 24.1.0\nMachine : arm64\nProcessor : arm\nCPU cores : 8\nArchitecture: 64bit\n\n"}],"execution_count":1},{"id":"fb19cecd-1fc9-4374-8854-a8bb85b5cae7","cell_type":"code","source":"import numpy\nimport shapely\n\n%watermark -w\n%watermark -iv","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:03:51.087648Z","iopub.execute_input":"2024-12-02T17:03:51.087748Z","iopub.status.idle":"2024-12-02T17:03:51.156882Z","shell.execute_reply.started":"2024-12-02T17:03:51.087734Z","shell.execute_reply":"2024-12-02T17:03:51.156667Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"Watermark: 2.5.0\n\nnumpy : 2.1.3\nshapely: 2.0.6\n\n"}],"execution_count":2},{"id":"c9c5a7c3-6b62-4dd3-840f-df03027f258f","cell_type":"markdown","source":"## 1. Functions","metadata":{}},{"id":"d89c115d-8f51-4872-8afe-b0a106438fb5","cell_type":"code","source":"def map_zip(line):\n \"\"\"Our current version.\"\"\"\n return list(\n map(shapely.LineString, zip(line.coords[:-1], line.coords[1:], strict=True))\n )","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:03:51.157205Z","iopub.execute_input":"2024-12-02T17:03:51.157372Z","iopub.status.idle":"2024-12-02T17:03:51.158957Z","shell.execute_reply.started":"2024-12-02T17:03:51.157364Z","shell.execute_reply":"2024-12-02T17:03:51.158781Z"},"trusted":true},"outputs":[],"execution_count":3},{"id":"32477b8b-db20-4ddc-b897-b1825ad2fe82","cell_type":"code","source":"def linestrings_column_stack(line):\n \"\"\"Proposed version.\"\"\"\n xys = shapely.get_coordinates(line)\n return shapely.linestrings(\n numpy.column_stack((xys[:-1], xys[1:])).reshape(xys.shape[0] - 1, 2, 2)\n )","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:03:51.159188Z","iopub.execute_input":"2024-12-02T17:03:51.159258Z","iopub.status.idle":"2024-12-02T17:03:51.160861Z","shell.execute_reply.started":"2024-12-02T17:03:51.159250Z","shell.execute_reply":"2024-12-02T17:03:51.160675Z"},"trusted":true},"outputs":[],"execution_count":4},{"id":"590cec86-7673-48ee-a73f-e942faf400c9","cell_type":"markdown","source":"## 2. Small Example\n### 2-coordinate LineString","metadata":{}},{"id":"5a6aa6be-7eb7-4802-9227-cbdde56a3b98","cell_type":"code","source":"line = shapely.LineString(((c,c) for c in range(2)))\nline.coords[:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:03:51.161183Z","iopub.execute_input":"2024-12-02T17:03:51.161273Z","iopub.status.idle":"2024-12-02T17:03:51.163947Z","shell.execute_reply.started":"2024-12-02T17:03:51.161266Z","shell.execute_reply":"2024-12-02T17:03:51.163767Z"},"trusted":true},"outputs":[{"execution_count":5,"output_type":"execute_result","data":{"text/plain":"[(0.0, 0.0), (1.0, 1.0)]"},"metadata":{}}],"execution_count":5},{"id":"639f087b-bde6-42ce-ada6-06685836ed15","cell_type":"code","source":"map_zip(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:03:51.165116Z","iopub.execute_input":"2024-12-02T17:03:51.165189Z","iopub.status.idle":"2024-12-02T17:03:51.166930Z","shell.execute_reply.started":"2024-12-02T17:03:51.165183Z","shell.execute_reply":"2024-12-02T17:03:51.166716Z"},"trusted":true},"outputs":[{"execution_count":6,"output_type":"execute_result","data":{"text/plain":"[<LINESTRING (0 0, 1 1)>]"},"metadata":{}}],"execution_count":6},{"id":"0bfe8a5d-75e2-4a69-88c1-dff1a3d277c3","cell_type":"code","source":"linestrings_column_stack(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:03:51.167180Z","iopub.execute_input":"2024-12-02T17:03:51.167242Z","iopub.status.idle":"2024-12-02T17:03:51.168965Z","shell.execute_reply.started":"2024-12-02T17:03:51.167236Z","shell.execute_reply":"2024-12-02T17:03:51.168810Z"},"trusted":true},"outputs":[{"execution_count":7,"output_type":"execute_result","data":{"text/plain":"array([<LINESTRING (0 0, 1 1)>], dtype=object)"},"metadata":{}}],"execution_count":7},{"id":"db98f488-85d5-476a-b9f3-2ddca827532f","cell_type":"markdown","source":"### Equivalent output?","metadata":{}},{"id":"350a2d8b-88b3-4bee-8b48-43a4045823ca","cell_type":"code","source":"all(shapely.equals(map_zip(line), linestrings_column_stack(line)))","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:03:51.169151Z","iopub.execute_input":"2024-12-02T17:03:51.169208Z","iopub.status.idle":"2024-12-02T17:03:51.170982Z","shell.execute_reply.started":"2024-12-02T17:03:51.169202Z","shell.execute_reply":"2024-12-02T17:03:51.170824Z"},"trusted":true},"outputs":[{"execution_count":8,"output_type":"execute_result","data":{"text/plain":"True"},"metadata":{}}],"execution_count":8},{"id":"ffef6810-094c-4f4c-97ec-f23bd6b75cee","cell_type":"markdown","source":"### Timing","metadata":{}},{"id":"a8075d40-3854-4e10-86a6-891aa0575d23","cell_type":"code","source":"%timeit map_zip(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:03:51.171271Z","iopub.execute_input":"2024-12-02T17:03:51.171361Z","iopub.status.idle":"2024-12-02T17:04:00.013821Z","shell.execute_reply.started":"2024-12-02T17:03:51.171355Z","shell.execute_reply":"2024-12-02T17:04:00.013514Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"11 μs ± 202 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n"}],"execution_count":9},{"id":"f47c0f0e-b7d7-46b9-b8e3-9e618774ae56","cell_type":"code","source":"%timeit linestrings_column_stack(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:00.014334Z","iopub.execute_input":"2024-12-02T17:04:00.014423Z","iopub.status.idle":"2024-12-02T17:04:03.304405Z","shell.execute_reply.started":"2024-12-02T17:04:00.014414Z","shell.execute_reply":"2024-12-02T17:04:03.304050Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"4.03 μs ± 30 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n"}],"execution_count":10},{"id":"1c33394b-b1b1-4b26-b516-a61603d21161","cell_type":"markdown","source":"## 3. Medium Example\n### 15-coordinate LineString","metadata":{}},{"id":"3459fa3d-b281-4727-a100-6ede9567da3f","cell_type":"code","source":"line = shapely.LineString(((c,c) for c in range(15)))\nline.coords[:3], line.coords[-3:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:03.304845Z","iopub.execute_input":"2024-12-02T17:04:03.304933Z","iopub.status.idle":"2024-12-02T17:04:03.307092Z","shell.execute_reply.started":"2024-12-02T17:04:03.304925Z","shell.execute_reply":"2024-12-02T17:04:03.306923Z"},"trusted":true},"outputs":[{"execution_count":11,"output_type":"execute_result","data":{"text/plain":"([(0.0, 0.0), (1.0, 1.0), (2.0, 2.0)],\n [(12.0, 12.0), (13.0, 13.0), (14.0, 14.0)])"},"metadata":{}}],"execution_count":11},{"id":"de750881-7f20-4720-80d8-3011bc9acd99","cell_type":"code","source":"_ = map_zip(line)\n_[:3], _[-3:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:03.307300Z","iopub.execute_input":"2024-12-02T17:04:03.307356Z","iopub.status.idle":"2024-12-02T17:04:03.309361Z","shell.execute_reply.started":"2024-12-02T17:04:03.307350Z","shell.execute_reply":"2024-12-02T17:04:03.309162Z"},"trusted":true},"outputs":[{"execution_count":12,"output_type":"execute_result","data":{"text/plain":"([<LINESTRING (0 0, 1 1)>, <LINESTRING (1 1, 2 2)>, <LINESTRING (2 2, 3 3)>],\n [<LINESTRING (11 11, 12 12)>,\n <LINESTRING (12 12, 13 13)>,\n <LINESTRING (13 13, 14 14)>])"},"metadata":{}}],"execution_count":12},{"id":"75789bd2-d433-4c57-8caa-8fbf2c0fcd09","cell_type":"code","source":"_ = linestrings_column_stack(line)\n_[:3], _[-3:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:03.309655Z","iopub.execute_input":"2024-12-02T17:04:03.309720Z","iopub.status.idle":"2024-12-02T17:04:03.311584Z","shell.execute_reply.started":"2024-12-02T17:04:03.309712Z","shell.execute_reply":"2024-12-02T17:04:03.311401Z"},"trusted":true},"outputs":[{"execution_count":13,"output_type":"execute_result","data":{"text/plain":"(array([<LINESTRING (0 0, 1 1)>, <LINESTRING (1 1, 2 2)>,\n <LINESTRING (2 2, 3 3)>], dtype=object),\n array([<LINESTRING (11 11, 12 12)>, <LINESTRING (12 12, 13 13)>,\n <LINESTRING (13 13, 14 14)>], dtype=object))"},"metadata":{}}],"execution_count":13},{"id":"553e251d-17a6-493d-8e44-4d6a17c74ffb","cell_type":"markdown","source":"### Equivalent output?","metadata":{}},{"id":"fc26d22f-14f4-4d4c-be11-6bd01f13dfe4","cell_type":"code","source":"all(shapely.equals(map_zip(line), linestrings_column_stack(line)))","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:03.311905Z","iopub.execute_input":"2024-12-02T17:04:03.312001Z","iopub.status.idle":"2024-12-02T17:04:03.313791Z","shell.execute_reply.started":"2024-12-02T17:04:03.311995Z","shell.execute_reply":"2024-12-02T17:04:03.313637Z"},"trusted":true},"outputs":[{"execution_count":14,"output_type":"execute_result","data":{"text/plain":"True"},"metadata":{}}],"execution_count":14},{"id":"53188d54-9b32-4235-acbf-99a92279b845","cell_type":"markdown","source":"### Timing","metadata":{}},{"id":"3c3d23b2-8cc3-4417-aee4-883832394158","cell_type":"code","source":"%timeit map_zip(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:03.314104Z","iopub.execute_input":"2024-12-02T17:04:03.314226Z","iopub.status.idle":"2024-12-02T17:04:06.774030Z","shell.execute_reply.started":"2024-12-02T17:04:03.314218Z","shell.execute_reply":"2024-12-02T17:04:06.773778Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"42.5 μs ± 304 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)\n"}],"execution_count":15},{"id":"c73c1616-e774-4991-98c0-ac345f2d3a85","cell_type":"code","source":"%timeit linestrings_column_stack(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:06.774465Z","iopub.execute_input":"2024-12-02T17:04:06.774543Z","iopub.status.idle":"2024-12-02T17:04:11.134665Z","shell.execute_reply.started":"2024-12-02T17:04:06.774535Z","shell.execute_reply":"2024-12-02T17:04:11.134444Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"5.34 μs ± 56.4 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)\n"}],"execution_count":16},{"id":"a8918005-067e-44d3-b938-9cae74bad8c7","cell_type":"markdown","source":"## 4. Large Example\n### 1,000-coordinate LineString","metadata":{}},{"id":"38a8cafa-b6cb-4750-8ae4-aac4be4cf2f4","cell_type":"code","source":"line = shapely.LineString(((c,c) for c in range(1_000)))\nline.coords[:3], line.coords[-3:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:11.135043Z","iopub.execute_input":"2024-12-02T17:04:11.135110Z","iopub.status.idle":"2024-12-02T17:04:11.137911Z","shell.execute_reply.started":"2024-12-02T17:04:11.135102Z","shell.execute_reply":"2024-12-02T17:04:11.137746Z"},"trusted":true},"outputs":[{"execution_count":17,"output_type":"execute_result","data":{"text/plain":"([(0.0, 0.0), (1.0, 1.0), (2.0, 2.0)],\n [(997.0, 997.0), (998.0, 998.0), (999.0, 999.0)])"},"metadata":{}}],"execution_count":17},{"id":"71cc64ea-68e8-4a7d-951b-ca31560eb61b","cell_type":"code","source":"_ = map_zip(line)\n_[:3], _[-3:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:11.138210Z","iopub.execute_input":"2024-12-02T17:04:11.138277Z","iopub.status.idle":"2024-12-02T17:04:11.143278Z","shell.execute_reply.started":"2024-12-02T17:04:11.138270Z","shell.execute_reply":"2024-12-02T17:04:11.143115Z"},"trusted":true},"outputs":[{"execution_count":18,"output_type":"execute_result","data":{"text/plain":"([<LINESTRING (0 0, 1 1)>, <LINESTRING (1 1, 2 2)>, <LINESTRING (2 2, 3 3)>],\n [<LINESTRING (996 996, 997 997)>,\n <LINESTRING (997 997, 998 998)>,\n <LINESTRING (998 998, 999 999)>])"},"metadata":{}}],"execution_count":18},{"id":"84a09ce2-b10a-4fcf-8250-2087441a9c36","cell_type":"code","source":"_ = linestrings_column_stack(line)\n_[:3], _[-3:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:11.143493Z","iopub.execute_input":"2024-12-02T17:04:11.143549Z","iopub.status.idle":"2024-12-02T17:04:11.145477Z","shell.execute_reply.started":"2024-12-02T17:04:11.143543Z","shell.execute_reply":"2024-12-02T17:04:11.145309Z"},"trusted":true},"outputs":[{"execution_count":19,"output_type":"execute_result","data":{"text/plain":"(array([<LINESTRING (0 0, 1 1)>, <LINESTRING (1 1, 2 2)>,\n <LINESTRING (2 2, 3 3)>], dtype=object),\n array([<LINESTRING (996 996, 997 997)>, <LINESTRING (997 997, 998 998)>,\n <LINESTRING (998 998, 999 999)>], dtype=object))"},"metadata":{}}],"execution_count":19},{"id":"8d719112-83d8-44b1-b303-97f032bb39f3","cell_type":"markdown","source":"### Equivalent output?","metadata":{}},{"id":"b3235781-21fb-4a55-b454-e84617f3b8b8","cell_type":"code","source":"all(shapely.equals(map_zip(line), linestrings_column_stack(line)))","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:11.145697Z","iopub.execute_input":"2024-12-02T17:04:11.145748Z","iopub.status.idle":"2024-12-02T17:04:11.153111Z","shell.execute_reply.started":"2024-12-02T17:04:11.145743Z","shell.execute_reply":"2024-12-02T17:04:11.152965Z"},"trusted":true},"outputs":[{"execution_count":20,"output_type":"execute_result","data":{"text/plain":"True"},"metadata":{}}],"execution_count":20},{"id":"e7bb7dc4-4fd4-40c5-ab42-5a1c4acbe6db","cell_type":"markdown","source":"### Timing","metadata":{}},{"id":"e97e41ab-e701-4122-a3e4-0fbdbe39860e","cell_type":"code","source":"%timeit map_zip(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:11.155011Z","iopub.execute_input":"2024-12-02T17:04:11.155071Z","iopub.status.idle":"2024-12-02T17:04:13.125059Z","shell.execute_reply.started":"2024-12-02T17:04:11.155065Z","shell.execute_reply":"2024-12-02T17:04:13.124849Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"2.43 ms ± 13.3 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"}],"execution_count":21},{"id":"a8a10750-c333-4c7c-9fcb-a5a8dd34603a","cell_type":"code","source":"%timeit linestrings_column_stack(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:13.125403Z","iopub.execute_input":"2024-12-02T17:04:13.125482Z","iopub.status.idle":"2024-12-02T17:04:21.852590Z","shell.execute_reply.started":"2024-12-02T17:04:13.125475Z","shell.execute_reply":"2024-12-02T17:04:21.852308Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"108 μs ± 802 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)\n"}],"execution_count":22},{"id":"a36330c3-dcd9-459e-ab51-48fbdc23f968","cell_type":"markdown","source":"## 5. Huge Example\n### 1,000,000-coordinate LineString","metadata":{}},{"id":"f738464e-6dbd-4aef-8098-d4e7c98c6a85","cell_type":"code","source":"line = shapely.LineString(((c,c) for c in range(1_000_000)))\nline.coords[:3], line.coords[-3:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:21.853033Z","iopub.execute_input":"2024-12-02T17:04:21.853109Z","iopub.status.idle":"2024-12-02T17:04:22.365510Z","shell.execute_reply.started":"2024-12-02T17:04:21.853102Z","shell.execute_reply":"2024-12-02T17:04:22.365228Z"},"trusted":true},"outputs":[{"execution_count":23,"output_type":"execute_result","data":{"text/plain":"([(0.0, 0.0), (1.0, 1.0), (2.0, 2.0)],\n [(999997.0, 999997.0), (999998.0, 999998.0), (999999.0, 999999.0)])"},"metadata":{}}],"execution_count":23},{"id":"e4446900-a0ad-4707-997b-416d081cbd88","cell_type":"code","source":"_ = map_zip(line)\n_[:3], _[-3:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:22.365955Z","iopub.execute_input":"2024-12-02T17:04:22.366042Z","iopub.status.idle":"2024-12-02T17:04:25.138804Z","shell.execute_reply.started":"2024-12-02T17:04:22.366034Z","shell.execute_reply":"2024-12-02T17:04:25.138482Z"},"trusted":true},"outputs":[{"execution_count":24,"output_type":"execute_result","data":{"text/plain":"([<LINESTRING (0 0, 1 1)>, <LINESTRING (1 1, 2 2)>, <LINESTRING (2 2, 3 3)>],\n [<LINESTRING (999996 999996, 999997 999997)>,\n <LINESTRING (999997 999997, 999998 999998)>,\n <LINESTRING (999998 999998, 999999 999999)>])"},"metadata":{}}],"execution_count":24},{"id":"1a6cae76-1673-4558-9f7e-0bc33cdb6df3","cell_type":"code","source":"_ = linestrings_column_stack(line)\n_[:3], _[-3:]","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:25.139178Z","iopub.execute_input":"2024-12-02T17:04:25.139251Z","iopub.status.idle":"2024-12-02T17:04:25.288436Z","shell.execute_reply.started":"2024-12-02T17:04:25.139244Z","shell.execute_reply":"2024-12-02T17:04:25.288205Z"},"trusted":true},"outputs":[{"execution_count":25,"output_type":"execute_result","data":{"text/plain":"(array([<LINESTRING (0 0, 1 1)>, <LINESTRING (1 1, 2 2)>,\n <LINESTRING (2 2, 3 3)>], dtype=object),\n array([<LINESTRING (999996 999996, 999997 999997)>,\n <LINESTRING (999997 999997, 999998 999998)>,\n <LINESTRING (999998 999998, 999999 999999)>], dtype=object))"},"metadata":{}}],"execution_count":25},{"id":"99ffc5be-19ae-4abe-9ff1-246391aef8b8","cell_type":"markdown","source":"### Equivalent output?","metadata":{}},{"id":"8ce7096b-7a2b-4ba9-aa80-40e8015d62ea","cell_type":"code","source":"all(shapely.equals(map_zip(line), linestrings_column_stack(line)))","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:25.288815Z","iopub.execute_input":"2024-12-02T17:04:25.288889Z","iopub.status.idle":"2024-12-02T17:04:30.175623Z","shell.execute_reply.started":"2024-12-02T17:04:25.288881Z","shell.execute_reply":"2024-12-02T17:04:30.175386Z"},"trusted":true},"outputs":[{"execution_count":26,"output_type":"execute_result","data":{"text/plain":"True"},"metadata":{}}],"execution_count":26},{"id":"ad33f0e1-c9f5-42ed-92f3-eb56ba289448","cell_type":"markdown","source":"### Timing","metadata":{}},{"id":"4b22d7d4-680c-4629-9358-63edafe1758f","cell_type":"code","source":"%timeit map_zip(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:30.175983Z","iopub.execute_input":"2024-12-02T17:04:30.176053Z","iopub.status.idle":"2024-12-02T17:04:50.390643Z","shell.execute_reply.started":"2024-12-02T17:04:30.176045Z","shell.execute_reply":"2024-12-02T17:04:50.390382Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"2.52 s ± 20.2 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"}],"execution_count":27},{"id":"c852e871-5629-468b-b875-914d529c3418","cell_type":"code","source":"%timeit linestrings_column_stack(line)","metadata":{"execution":{"iopub.status.busy":"2024-12-02T17:04:50.390977Z","iopub.execute_input":"2024-12-02T17:04:50.391053Z","iopub.status.idle":"2024-12-02T17:05:00.349094Z","shell.execute_reply.started":"2024-12-02T17:04:50.391045Z","shell.execute_reply":"2024-12-02T17:05:00.348856Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":"123 ms ± 1.13 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"}],"execution_count":28}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment