Skip to main content

Maccarone: AI-managed code blocks in Python ⏪⏩

PyPI version

Maccarone lets you delegate sections of your Python program to AI ownership.

Here's what it looks like in the VS Code extension:

screencap-20230629

Example

You might write some code like this:

def main(path: str):
    #<<filenames = a list of filenames under path>>

    for fn in filenames:
        #<<size = size of fn in bytes>>

        print(fn, size)

#<<use argparse and call main>>

Maccarone then fills in the sections you've delegated:

def main(path: str):
    #<<filenames = list of filenames under path; no dirs>>
    import os
    filenames = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
    #<</>>

    for fn in filenames:
        #<<size = size of fn in bytes>>
        size = os.path.getsize(os.path.join(path, fn))
        #<</>>
        print(fn, size)

#<<use argparse and call main>>
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("path", type=str)
args = parser.parse_args()
main(args.path)
#<</>>

Make a change in your code, like adding an extension parameter to main, and Maccarone keeps its sections up to date:

def main(path: str, extension: str | None = None):
    #<<filenames = list of filenames under path; no dirs>>
    …
    if extension:
        filenames = [f for f in filenames if f.endswith(extension)]
    #<</>>
    …

#<<use argparse and call main>>
…
parser.add_argument("--extension", type=str, default=None)
args = parser.parse_args()
main(args.path, args.extension)
#<</>>

Quickstart

Prerequisites

  • Python 3.8+
  • OpenAI API key with GPT-4 (export OPENAI_API_KEY)

Easy Mode - VS Code Extension

Easy mode is the free extension from the VS Code marketplace.

Install it in VS Code and you're done (if you have the prerequisites above).

Other Option - Command Line

If you don't use VS Code, you can still install Maccarone directly from PyPI:

  • pip install maccarone

Then run maccarone to generate code and update your source file:

$ maccarone --rewrite examples/file_sizes.py

Usage notes

Running maccarone on a directory

Maccarone can rewrite all files in a directory:

$ maccarone --rewrite --suffix .py examples/

Be careful! You should probably run this only on files in source control, for example.

FAQs

It needs my OpenAI API key?

Maccarone prompts GPT-4 to write code. It will make OpenAI API calls using your key and you will be charged by OpenAI.

API calls are made every time Maccarone preprocesses a new version of a source file.

The number of tokens consumed is proportional to the size of your completed code. You cannot accurately predict that number in advance. A small source module might cost $0.01–0.10 to preprocess.

What prevents my program from behaving differently after each preprocessing run?

The strength of your faith in GPT-4.

What about non-English languages?

They are likely to work, but less likely than English.

What does "maccarone" mean?

https://en.wikipedia.org/wiki/Macaronic_language

Metadata

Release files for maccarone 0.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maccarone 0.1.9
File Size Uploaded Provenance
maccarone-0.1.9.tar.gz 14.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for maccarone 0.1.9
File Interpreter ABI Platform
maccarone-0.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 24.3 kB

Release files / maccarone-0.1.9.tar.gz

Download URL maccarone-0.1.9.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9d61f311b73e6f26f66146515dd3186bd61f6b5e654752978b9271b044c4b147
BLAKE2b-256 checksum
How to use checksums
7bbb85cd988cd45eee021a2b8915f16dfc1470d6b8a45f3cbcbba73888da49e1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.17

Release files / maccarone-0.1.9-py3-none-any.whl

Download URL maccarone-0.1.9-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a24aa7940602807c9f7542bd49f7407fde95ce54d4b2dfcf76bac8740c11acb
BLAKE2b-256 checksum
How to use checksums
9dc50224ae045ef187ba2485c3de89f422650511b0b38578cc1549e0caaff6fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.17

Security for maccarone 0.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page