Package: warpcore
warpcoreStreamlined multi-threaded process accelerationWhen working with software that needs to be performant, it’s challenging to deal with all the pitfalls of multi-threading while balancing code stability.Smoothing out the bumps in the road to multi-threading is the primary goal of the project. It’s just that simple.InstallationOS X, Linux & Windows:pipinstallwarpcoreUsage ExamplesList OperationsBuild a list of arguments that will be passed to a designated function.jobs=[]jobs.append("Picard")jobs.append("Janeway")jobs.append("Kirk")jobs.append("Sisko")jobs.append("Archer")Create a function that will iterate over the list:defdo_the_thing(name):print(f"Star Fleet Captain{name}")Create a single-threaded version to test:fornameinjobs:do_the_thing(name)Once that works, convert the for-loop into a warpcore callwarpcore.list_engage(jobs,do_the_thing)Full example:fromwarpcore.engineeringimportWarpCoredefdo_the_thing(name):print(f"Star Fleet Captain{name}")jobs=[]jobs.append("Picard")jobs.append("Janeway")jobs.append("Kirk")jobs.append("Sisko")jobs.append("Archer")# Single-threaded operation (for testing/debug)# for name in jobs:#     do_the_thing(name)# Multi-threaded operation (for normal operation)warpcore=WarpCore()warpcore.list_engage(jobs,do_the_thing)Please refer toexample0.pyandexample1.pyfor basic and more advanced usage examples respectively.Dictionary OperationsBuild a dict of arguments that will be passed to a designated function.database={"Picard":"USS Enterprise-D","Janeway":"USS Voyager","Kirk":"USS Enterprise-A","Sisko":"Deep Space 9","Archer":"Enterprise NX-01"}Create a function that will iterate over the dictionary:*Note when using dicts, make sure your worker function accepts thekeyandvalueas arguments. (See below)defdo_the_thing(key,value):print(f"Star Fleet Captain{key}is/was in command of{value}")Create a single-threaded version to test:forkey,valueindatabase.items():do_the_thing(key,value)Once that works, convert the for-loop into a warpcore callwarpcore.dict_engage(database,do_the_thing)Full example:fromwarpcore.engineeringimportWarpCoredefdo_the_thing(key,value):print(f"Star Fleet Captain{key}is/was in command of{value}")database={"Picard":"USS Enterprise-D","Janeway":"USS Voyager","Kirk":"USS Enterprise-A","Sisko":"Deep Space 9","Archer":"Enterprise NX-01"}# Single-threaded operation (for testing/debug)# for key, value in database.items():#     do_the_thing(key, value)# Multi-threaded operation (for normal operation)warpcore=WarpCore()warpcore.dict_engage(jobs,do_the_thing)Fine Tuning for PerformanceTL;DR:example2.pyIs a working sample of the profiling system.Your workload and processor architecture will dictate which settings work best for any situation.You can leave things at default, but if you want to squeeze even more performance out, consider using the profiling feature.# Regular operationwarpcore.list_engage(tasks_list,do_the_thing)# Performance Profiling mode of same function as abovewarpcore.list_profile(tasks_list,do_the_thing)Profiling simply runs your code, but benchmarks execution time of the full job list. Then tweaks the settings and re-runs the jobs again.Each time it re-runs, it displays the performance metrics of the last run on console.Once complete, it will display the suggested combination of settingsExample 1RESULTS:Bestperformance(85.8%gain)using*compute:True*withmax_parallel:51This translates to the following setup:warpcore=WarpCore(51)warpcore.list_engage(tasks_list,do_the_thing,compute=True)Example 2RESULTS:Bestperformance(91.4%gain)using*compute:False(Default)*withmax_parallel:32This translates to the following setup:warpcore=WarpCore(32)warpcore.list_engage(tasks_list,do_the_thing,compute=False)# or just leave out 'compute' keyword to assume Falsewarpcore.list_engage(tasks_list,do_the_thing)MetaBrandon Blackburn –PGP Encrypted Chat @ KeybaseDistributed under the Apache 2.0 license. SeeLICENSEfor more information.TL;DR:For a human-readable & fast explanation of the Apache 2.0 license visit:http://www.tldrlegal.com/l/apache2https://github.com/BlackburnHax/warpcore