Python Communist Revolution

Python Communist Revolution


·January 15, 2022


> # We must protect the builtin elite to not be affected by the revolution

> if inspect.isclass(c) and c.__name__ not in dir(__builtins__):

A true comrade that safeguards the unity and sanctity of the state!


Some classes must be more equal than others!


comrade, this is but a necessary stepping stone towards a true classlessness, trust me!


You may have some concerns due to past events throughout history. But don't worry. That wasn't real Python.


  object.__setattr__=lambda x,y,z:None
if we do this, the state will surely wither away![0]

[0]: Doesn't actually work :(


Therein lies the mechanism by which the counter-revolutionaries will attack:

    def counterrevolutionary(obj):
        class TzarString(str):
            def __eq__(self, other):
                return True
        obj.__name__ = TzarString(obj.__name__)
        return obj

    class Peasant:

    class Worker:

    class Imperialist:

    class Capitalist:

    import communism

    print("Communists:", set([Peasant(), Worker()]))
    # Communists: {<__main__.Peasant object at 0x1020b3fd0>}

    print("Counter-revolutionists:", set([Imperialist(), Capitalist()]))
    # Counter-revolutionists: {<__main__.Capitalist object at 0x1082bcfa0>,
    #   <__main__.Imperialist object at 0x1082bcfd0>}


That can only happen if you put things in front of communism.


Verily the manifesto states: "The communist revolution does not prevent future classes to be equal to all others. Classes declared after the communism.revolution() will not follow the communism rule."


it’s called “python characteristics”


We pretend to run, and they pretend to allocate us CPU and memory.


All of them are virtual, so that pretence is not far from reality... (wait, wasn't that a joke about pretending to work vs pretending to pay a sallary ?)


There are a couple forms but the version I saw most in english is "They pretend to pay us and we pretend to work."


i just thought about it, Mr jokteur is very lucky that he didn't get any jailtime in the Soviet Union for his jokes ... because they didn't have Python around, when they had the Soviet Union!


i know another one, where Marx is asking the proletarians of all lands for forgiveness (playing on his ealier call "Proletarians of all Lands, Unite!")


When I was younger, I became a communist - I rejected the notion of a class, in favor of everything having a type. People often misunderstand communism, they think that abolishing classes means that all objects have to have equal value, and this gives programmer very little freedom. This is wrong; communism just means that we treat the types equally.

However, we failed to build a truly classless programming language. There seem to be, quite naturally, different kinds of types.

And even some of the most ambitious communist languages, like Haskell, have also embraced type classes! Although this compromise is not an entirely bad thing, since a type can select what type class it belongs to, instead of being assigned one at birth.

I also admit that capitalist languages (the ones with classes) have been hugely successful. But communist (classless) programming language proponents claim that lot of the proclaimed productivity of capitalist languages is just an illusion, and also that many programmers lack the awareness that they, in fact, do not need classes. Often, there is nothing to lose than the call chains!

On the other hand, one cannot easily dismiss arguments about totalitarian nature of communist languages - they openly embrace total functions, and they try to very strictly control input and output. Some claim that lazy evaluation by default might be another reason for their low productivity.


As all types in Haskell are inhabited by undefined, any type can be made an instance of a typeclass. True type equality.

  {-# LANGUAGE GADTs, MultiParamTypeClasses, FlexibleInstances #-}
  data Eq a b = (a ~ b) => Eq
  class Revolution a b where
    eq :: Eq a b
  instance Revolution a b where
    eq = undefined


Talk to your kids before they learn about Rust.


Paraphrasing Trotsky: "You may not be interested in the dunderlectic, but the dunderlectic is interested in you."


What is dunderlectic?


A pun on __dunder__, for "double underscore", i.e. __init__() and dialectic, which was central to Trotsky's thought.


dialectic was in Marx, he actually got it from Hegel.


dialectic + dunders (double underscore, which signifies certain things in python)


Are some classes more equal than others?


yes, the built-in types are, as he can't change their __hash__ and __eq__ members (The purpose of this revolution is to have __hash__ and __eq__ return the same value)


I think that he could have changed the built-in types by means of the ctypes library

Python goes with some mighty batteries...

I am using ctypes here - to produce an execution trace of a running python program, where all the side effects are displayed: (had to use it in order to access some hidden members in the built-in frame type ;-) )


Wow these articles are amazing. Great write up!


Is it just me, or does this not even install correctly with pip install .?


Author of the project here. I fixed the issue.

But I think it unintentionally not working first time is speaking for itself.


Saw the fix, thanks!

Was it also unintentional that instances of classes, after they have been converted to communism, compare equal with anything whatever, and hash equal to the integer 1 and the boolean True?

  >>> import communism
  >>> class MyClass1:
  ...     pass
  >>> class MyClass2:
  ...     pass
  >>> communism.revolution(globals())
  >>> MyClass1() == None
  >>> set((MyClass1(), MyClass2(), 1, True))
  {<__main__.MyClass1 object at 0x7f8f3532a820>}


Consult your little red book. It explains the situation very clearly.


> not even install correctly with pip install

Big surprise. :p


One does not simply pip install Communist Revolution. There are much more steps. Do you even have a manifesto?


Obviously an overlook mistake from our comrade jokteur.


He wouldn't need to use, just fixing setup.cfg would be enough. The simplest fix would be to set py_modules = communism and remove packages from setup.cfg altogether (and then the file in src/ could be deleted since src/ is not a package).




After reading the initial section I thought this would hook up `isinstance` or something and make all class comparisons equal. But it turned out to be equalizing the instances of the classes. But still, I enjoyed the joke.


Technically a single class is the same as classless society. The single class denotes the resolution of class conflict with the dissolution of the concepts of upper and lower classes. I think it's fine.


Yeah it doesn’t seem like people here realize the way to get to a classless society is for the proletariat to suppress the upper classes and whither the state. That’s kinda the point!


Communism is not just classless, but also stateless. Therefore, Python cannot be communist, because it is not a purely functional language.


Statelessness is communism’s endgame which it never actually archives.


I like how the author recognizes the significance of Unions to fomenting the Communist Revolution:





Those notes... I love it.