Git Product home page Git Product logo

acepy's Introduction

AcePy

Automatic Concurrent Execution in Python

AcePy: Write simple single threaded Python code but get all the performance benefits of multithreading for free!

Given a list of tasks, AcePy finds the most optimal sequence to complete the tasks, executing them in parallel whenever possible. AcePy accomplishes this automatically, and requires minimal refactoring of your code to work.

For example, suppose we are building a dashboard for an online shopping site. Suppose we need to do the following API/RPC calls to get all the relevant data to show.

  1. getUserIdFromLoginData(data), which fetches the userId used thought our application.
  2. getMembershipStatusFromUserId(id), which retrieves whether the user is a premium member in our online shopping site (like Amazon Prime)
  3. getCurrentDiscounts(), which retrieves a list of all discounted products available now
  4. isEligibleForDiscount(status, discounts), which determines if a user is eligible for any discounts based on their membership status

To write the code to accomplish the above tasks, we can just call each function from top to bottom. Each time a function finishes, we forward its return value into the parameter of the next function that needs it. It is easy to write the code to do these tasks one by one.

However, if we want to reduce some time waiting on IO operations to complete, then we could instead execute the functions concurrently. But, we can't just do all of them at once. For example, isEligibleForDiscount depends on membership status and the available discounts, thus can only be run once everything else has been completed.

In this small example it is not too hard to figure out which functions can be called concurrently and which need to wait for others to finish. However, in a larger codebase it can be extremely difficult to find the most optimal scheduling. As a result, manually writing the code to chain together IO tasks is very error prone, hard to read, and often times suboptimal.

AcePy lets you do just the easy work, which is simply writing out the tasks one by one. AcePy then analyzes your code to find the optimal ordering to execute every task. The result: write simple single threaded code but get all the performance benefits of multithreading for free!

acepy's People

Contributors

novacer avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.