#metaprogramming
Explore tagged Tumblr posts
Text
MetaGPT is a framework that enables you to use natural language to create and execute meta programs for multi-agent collaboration and coordination. Meta programs are programs that can generate or modify other programs based on some input or context. In this article, you will find out how MetaGPT works, what are its key features and capabilities, and how it compares to other frameworks.
#MetaGPT#MultiAgent#MetaProgramming#AI#Opensource#datascience#MachineLearning#open source#artificial intelligence#machine learning#programming#data science
2 notes
·
View notes
Text
Hoy veremos como usar metaprogramacion como un paradigma para la programacion funcional. Espero les sea de utilidad y tengann un buen finde!
0 notes
Text
it doesn't matter 'what time it "is"' for computers to do their computing
setting the locale of my pc to the dawn on the krita yuga
doing all my computing from a mythical point in an idyllic future, as though
(similarly, your subconscious mind is not bound to the present, it can do all of its thinking anywhen and always)
0 notes
Text
Why yes, I am posting a C++ programming meme to tumblr. It’s as close as I come to a fandom.
(with the caveat that C++ is intensely problematic on a number of levels. Nonetheless, it is my axe.)
1 note
·
View note
Text
Those easier paths of avoidance are illusions. They lead in loops, and soon enough we find ourselves right back in the self-same space we've created.
Everywhere you look, you will always find you. Everywhere you run, you will always be faced with the truth.
#consciousness#awareness#creation#you can't hide from your truth#truth#acceptance#love#perspective#illusions#samsara#love metaprograms
6 notes
·
View notes
Text
Again at its core its like, the duality btween c-3po utterly sort of refusing to be happy, but also Not Enjoying It is the only real choice he has about his life so
#in the I Will But I Wont Enjoy It school of thought pushed to the far far edge#his metaprogramming is IN THE MERE FACT HE HAS SO MANY GODDAMN OPINIONS it should be considered a miracle not a problem
3 notes
·
View notes
Text
okay i more or less know how to phrase what i want help with now but its also 2 In The Morning and its way too late to actually be getting help with jackshit
#sigh. i love racket when it's simple but hate it when its not#there needs to be an entire fucking book on just the metaprogramming aspects#because the official documentation really isn't interested in delving into it beyond the very basics#and then assuming you know everything about it and need a small refresher
1 note
·
View note
Text
Metaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
Welcome to Python Metaclasses! To truly grasp the concept of metaclasses, we need to start by understanding a fundamental principle of Python: everything is an object. Yes, that includes classes themselves. We’ll explore the nature of objects, the functionality of the type() function, how classes instantiate objects, and the intriguing process of instantiating classes, which are objects in their own right. We’ll also discover how to tap into this mechanism to achieve remarkable results in our code.
Once we’ve covered the fundamental concepts of metaclasses, we’ll dive into a real-world example: the Enum class and its companion, the EnumType. This case study will showcase how metaclasses can be used effectively in practice.
Exploring Types and Unveiling Objects: Demystifying the type() Function
Python considers everything to be an object, and each object has a type that describes its nature. Numbers, for example, are of the type “int”, text is of the type “str”, and instances of a custom Person object are of the type “Person” class.
The type() method is a useful tool for determining the type of an object. Let’s experiment with it in the Python REPL. For example, when we create a list and use type() on it, we discover that it is an object instance of the “list” class. We can also ascertain the type of a string, such as “cat,” which is, predictably, “str”. In Python, even individual letters are considered strings, unlike some other programming languages that distinguish between characters and strings.
In fact, the “type” function is at the top of the class hierarchy. Just as calling “str()” on an object returns its string representation, calling “type()” on an object returns its type equivalent. It’s worth reiterating that “type” is the highest point in this hierarchy. We can confirm this by observing that the type of “type” is also “type”.
>>> print(type(1)) <type 'int'> >>> print(type("1")) <type 'str'> >>> print(type(ObjectCreator)) <type 'type'> >>> print(type(ObjectCreator())) <class '__main__.ObjectCreator'>
Well, type has also a completely different ability: it can create classes on the fly. type can take the description of a class as parameters, and return a class.
type works this way:
type(name, bases, attrs)
Where:
name: name of the class
bases: tuple of the parent class (for inheritance, can be empty)
attrs: dictionary containing attributes names and values
type accepts a dictionary to define the attributes of the class. So:
>>> class Foo(object): ... bar = True
Can be translated to:
>>> Foo = type('Foo', (), {'bar':True})
And used as a normal class:
>>> print(Foo) <class '__main__.Foo'> >>> print(Foo.bar) True >>> f = Foo() >>> print(f) <__main__.Foo object at 0x8a9b84c> >>> print(f.bar) True
You see where we are going: in Python, classes are objects, and you can create a class on the fly, dynamically.
This is what Python does when you use the keyword class, and it does so by using a metaclass.
Discovering Python’s Class Instantiation
Dynamic class creation is a great Python feature that allows us to construct classes on the fly, giving our code flexibility and extensibility. In this section, we will look at how to construct classes dynamically using metaprogramming techniques.
But it’s not so dynamic, since you still have to write the whole class yourself.
Since classes are objects, they must be generated by something.
When you use the class keyword, Python creates this object automatically. But as with most things in Python, it gives you a way to do it manually.
Dynamic class creation is the foundation of metaclasses, which are classes that define the behavior of other classes. Metaclasses allow us to intercept class creation and modify attributes, methods, and behavior before the class is fully formed. However, exploring metaclasses goes beyond the scope of this section, as it requires a deeper understanding of Python’s metaprogramming capabilities.
What are metaclasses (finally)
Metaclasses are the ‘stuff’ that creates classes.
You define classes in order to create objects, right?
But we learned that Python classes are objects.
Why would you use metaclasses instead of function?
The main use case for a metaclass is creating an API. A typical example of this is the Django ORM. It allows you to define something like this:
class Person(models.Model): name = models.CharField(max_length=30) age = models.IntegerField()
But if you do this:
person = Person(name='bob', age='35') print(person.age)
It won’t return an IntegerField object. It will return an int, and can even take it directly from the database.
This is possible because models.Model defines __metaclass__ and it uses some magic that will turn the Person you just defined with simple statements into a complex hook to a database field.
Django makes something complex look simple by exposing a simple API and using metaclasses, recreating code from this API to do the real job behind the scenes.
Conclusion
Although magicians are not meant to share their secrets, understanding metaclasses allows you to solve the puzzle for yourself. You’ve learned the key behind several of Python’s finest techniques, including class instantiation and object-relational mapping (ORM) models, as well as Enum.
It’s worth mentioning that creating bespoke metaclasses isn’t always necessary. If you can address the problem in a more straightforward manner, you should probably do so. Still, understanding metaclasses will help you understand Python classes in general and recognise when a metaclass is the best tool to utilize.
Originally published by: Metaclasses – Python’s Object-Oriented Paradigm and Its Metaprogramming
#Metaclasses in Python#Metaprogramming with Metaclasses#OOP in Python#Python Metaclasses#Python Object Oriented Paradigm
0 notes
Text
"A Mysterious and Tender Power"

~by Cedar Sun
Here is the newest painting! A little piece of the peace of my heart.
Sometimes we may become disturbed and disarrayed, because we have become lost within our minds and our thoughts. Let us brush away the fear words whispered by the thoughtworld, all the futile flighty attempts to control our lives and the lives of others, and live once more in our hearts.
It is our hearts which will show us the mysterious and tender powers of our soul, of our world.
If we can live in our hearts, we will gain new strength, new confidence. It is not strength which will protect us from pain, for pain is its own blessing, but strength which will carry our soul through the greatest depths and heights of this world, and allow us to know every vital moment in its purest truth, without illusions, without deception.
#heart space#heart#love#peace#painting#light work#painter#cedar sun art#my painting#quotes#buddhism#love metaprograms#art#writing
4 notes
·
View notes
Text
1. What keyword and structure is used as an implicit type parameter in order to implement type-level higher-order functions within the Typescript type system?
2. What 3 famous chord progressions are employed throughout the song Coil from Old School RuneScape?
3. How many 4-beat weave patterns are possible to perform with regular poi and a single one in each hand?
Thinking about this metric of like...
Come up with a set of three general-knowledge questions (by general knowledge I mean not stuff about your personal life; roughly the type of information you might find in a Wikipedia article) that you think uniquely narrow you down, in the sense that you feel confident you are the only person on earth who could answer all three questions correctly.
I can think of a few question sets like this for me, where I'm like 80% confident that I'm the only person who knows the answer to all three of them. If you have a little bit of obscure knowledge on a couple of topics, this is fairly easy to do I think.
Well, then the question is, how many meaningfully distinct sets of three questions like this do you have. Call that number your Obscurity Rank.
It's pretty cool to be of high Obscurity Rank, and one should strive for it.
#I picked these because none of these appear to have good documented wikis anywhere but theoretically could.#TS metaprogramming has a small enthusiast community but I don't know of any documentation#OSRS wiki is great but doesn't do music theory#and if there's a good poi wiki I've never seen it
155 notes
·
View notes
Text
C++ / TMP - Polimorfismo estatico
Hoy les traigo otra etapa mas de la metaprogramacion de template. Espero les sea de utilidad!
Bienvenidos sean a este post, hoy veremos una de las etapas de TMP. En este post hablamos sobre polimorfismo, y podemos resumirlo como multiples funciones bajo el mismo nombre. Siendo que el polimorfismo dinamico nos permite determinar la funcion actual que usaremos al momento de ejecucion. En cambio, el polimorfirmo estatico solo sabra la funcion actual que debe correr al momento de la…
0 notes
Text
"You want to see something gross?" "YES!!!! *long pause* ewwwwww....."
did i hear this conversation between:
(1) two lil kiddos on the playground marveling over a dead bug, or
(2) two horrifyingly skilled c++ programmers, one of whom has just sinned against God personally via template metaprogramming & the other who is encouraging that nonsense
44 notes
·
View notes
Text
honestly don't hate OOP despite being a seething functionalcel. like obviously polymorphism is the wrong way to go about it, we know that now, but if you don't fuck up exactly like java but on purpose you're fine. you can imitate all kinds of like metaprogramming stuff without making syntax weird
101 notes
·
View notes
Text
I receive by giving,
I command by allowing
Everything, for nothing
And nothing, for everything
5 notes
·
View notes
Text
(Nearly) Never use auto in C++!!!
So I used to be amongst the people who thought "Yeah ok, auto hides the type. But if the type is not really important to understand the code, and was really long and confusing then it is worth it"
Like this: std::vector<std::pair<std::string, Employee>> MyFunction(); To turn it into: auto MyFunction();
And I was wrong. Do NOT use auto to hide that monstrosity. You FIX it. auto hides that awful thing and dumps the problem on the next poor fucker who will use it. ( People writing and using metaprogramming libraries are especially prone to doing this, since their typenames can fill entire screens ).
YOU just looked at YOUR code. Found it confusing... And decided... to HIDE it??? What it is the next person who did NOT write this code going to do when they read this going to do???
No. I beg of you. Use typedef.
You can create aliases of anything and make your code easy to read. And this only "hides" the code as much as auto and you can get the types the alias points to by musing over it. So it is auto... but way better. Because it is a UNIQUE name. Which can DESCRIBE things.
Like, with the horror in the previous example. Let us have a typedef in the .hpp file where "MyFunction" is declared. Now it reads MUCH better:
std::vector<std::pair< Employee_ID, Employee>> MyFunction();
I actually understand what the pair is now! Key value pairs! And screw it. Let us typedef the pair too now that we understand it!
std::vector<Employee_KeyValuePair> MyFunction();
And fuck it. Once more! Typedef the vector too!
Employee_Roster MyFunction();
I will bet most of you reading this only realized what the hell that moster was when you got near the end. BECAUSE THE FIRST THING IS FREAKING UNREADABLE! Fix it. Make your code readable. If you feel the urge to use an auto to hide a typename, it is time to typedef that motherfucker!
227 notes
·
View notes