Skip to main content

Cuboid Raptor's Lib Rary, A Garbage Collection Of Garbage For Your Garbage Needs™

Project description

This is a random library I made with random garbage I made that occasionally can help with programming. It’s just the must random code crammed into one poopy doopy thing maintained by a dumbo octopus, so use this at your own risk. Also sorry if the docs are garbage I’m lazy ight

Docs…?

  • crlib.recursion() ; A context manager that lets you temporarily set your recursion depth. Use:

    with crlib.recursion(<some recursion limit here>):
        <do something here>

    Your recursion limit will be reset after.

  • crlib.suppress() ; A suppression context manager, use it with the “with” keyword like crlib.recursion(). This will temporarily suppress stdout and stderr, preventing anything from being printed to console, even with sys.stderr.write. This will, however, not silence error messages, although that’s probably a good thing.

  • crlib.pubsub() ; Class that lets you use a publish subscribe model. You can create an instance, then publish/subscribe to that instance.:

    ps = crlib.pubsub()
    
        def foo(bar):
            return bar + 1
    
        sid = ps.subscribe("baz", foo)
    
        print(ps.publish("baz", [7]))
    
        ps.unsubscribe(sid)

    This will print [8]. There is also crlib.pubsub().clear(), which clears all subscribers and crlib.pubsub().view(), which will pretty print the cache.

  • crlib.find_args(func) ; Tries, tries, to return a list of all arguments of function.

  • crlib.blob(in, out) ; Takes a binary input file and converts it into a python script so that when said script is imported and the .unblob(out) method is run, it unblobs it’s data to out. Can be used for easy pyinstallering.

  • crlib.test() ; idfk figure it out

  • crlib.gc() ; Nuclear bomb every variable in namespace, absolutely the most performant GC out there.

  • crlib.cfor() ; C-style for loops

  • crlib.lazy_import() ; Lazy import, you can do it in bulk with lists, and use semicolons as import as and slashes are try: import except; import For example, "numpy;np" imports numpy as np, and ujson;json/json tries to import ujson as json, and if ujson doesn’t exist on your python installation, it imports json instead.

  • crlib.nh_cache() ; FIFO cache that supports non-hashable objects and can deepcopy return values if needed.

  • crlib.lru_cache() ; Extension of functools.lru_cache that supports deepcopying results with copy arg

  • crlib.silence(func) ; Runs functions and prints tb + return error message and continues if error

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crlib-1.2.1.tar.gz (18.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page