AI (Artificial Intelligence)

I suspect some plugin code will look different by then (check demos):

(But currently training data only up to September 2021, i. e. KiCad 5.1 bindings… Maybe make sure KiCad and plugins have active mirrors on GitHub since they use it for training data.)

Hmm…, people could now understand what my code does…


# Python 2 
    from functools import cache
except ImportError:
    def cache(function):
        from functools import wraps
        from collections import defaultdict
        class cachedict(defaultdict):
            def __missing__(self, key):
                self[key] = val = self.default_factory(*key)
                return val
        cache = cachedict(function)
        def wrapper(*args):
            return cache[args]
        wrapper.cache_clear = cache.clear
        return wrapper

# Explanation of what the code in the exception clause does


# The cache decorator is a memoization decorator. It caches the return value of the decorated function.
# The first time the function is called, the return value is cached.
# The next time the function is called with the same arguments, the cached value is returned.
# This is useful for expensive functions that are called repeatedly with the same arguments.

# The code in the exception clause is a reimplementation of the cache decorator.
# It uses a defaultdict to cache the return values of the decorated function.
# The defaultdict is initialized with the decorated function.
# The __missing__ method of the defaultdict is overridden to call the decorated function with the missing key.
# The return value of the decorated function is stored in the defaultdict and returned.
# The cache is cleared by calling the cache_clear method of the wrapper function.

# The cache decorator is available in Python 3.2 and later.
# The code in the exception clause is a reimplementation of the cache decorator.
# It is compatible with Python 2.6 and later.
# It is not compatible with Python 3.2 and later.
# It is not compatible with Python 3.2 and later because the cache decorator is available in Python 3.2 and later.

FYI, introduced yesterday. Might be interesting for FAQs in this forum at some point.

Doesn’t someone/s still write a programme and the computer just does as it’s told?

Yes, but now in much more general terms. Like in the OpenAI case, they’ve trained the codex model with (all) public repositories from GitHub, so if you use the correct instructions (wording/direction/follow-up questions), it could assemble almost anything that has some similarity to some code fragments there. It’s very good at completing code fragments if you write the “right” first few words (so far mostly Python and JavaScript, though).

In above first case, AI explained what the code does and even why (sometimes a coder doesn’t even know himself). So this could be useful for code submissions (merge requests, plugins, etc.). Or just to understand what the developers changed before the documentation is ready (if ever, but it can also be used to document code). Or let it design a plugin API.

A second case is answering questions, like here in the forum.

Currentness is currently the same (up to 2021-09):

:rofl: I guess one of the issues is that it doesn’t actually have current access to the internet (it’s almost 2 years behind – unlike apparently Bing Chat). But it knows about KiCad…

Interesting topic. Gotta see it keeping some time in hand. Thanks.

Isn’t it interesting to do it yourself? Draw Board Create Code? Use the Internet as a tool for information and not make it a means of work?)

Ha, maybe someday AI will design boards and the unit fanatics will have to find some other cause to espouse. :rofl: