vimrc

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules

commit 67253492ca8c3668172000552663754d4d16a9c9
parent 44604a6a4588c98bf76239f299d7ce8957c8d64a
Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe>
Date:   Mon, 24 Apr 2023 09:31:42 -0500

Added some python ultisnippets

Diffstat:
MUltiSnips/python.snippets | 37++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets @@ -17,6 +17,7 @@ endsnippet snippet for "for loop" b for ${1:item} in ${2:iterable}: ${3:${VISUAL:pass}} +$0 endsnippet # --------------------------------------------- # @@ -354,7 +355,6 @@ while running: dt = clock.tick(60) / 1000 pygame.quit() - endsnippet @@ -375,3 +375,38 @@ ${2:project_description} __version__ = "${3:0.1}" endsnippet + +snippet ppe "ProcessPoolExecutor" b +with concurrent.futures.ProcessPoolExecutor(max_workers=${1:4}) as executor: + ${0:emap or cfac} +endsnippet + +snippet tpe "ThreadPoolExecutor" b +with concurrent.futures.ThreadPoolExecutor(max_workers=${1:4}) as executor: + ${0:emap or cfac} +endsnippet + + +snippet emap "executor.map" b +for result in executor.map(${1:func}, ${2:iterable}): + ${3:pass} +endsnippet + +snippet cfac "executor.map" b +futures = (executor.submit(${1:func}, ${2:args}) for $2 in ${3:iterable}) + +for future in concurrent.futures.as_completed(futures): + result = future.result() + $0 +endsnippet + + +snippet perf_counter "time.perf_counter()" b +start = time.perf_counter() + +${1:${VISUAL:pass}} + +end = time.perf_counter() +print(f"It took: {end - start:.2f}s") +$0 +endsnippet