#esoteric-python
1 messages · Page 7 of 1
class Solution:
def fib(self, n: int) -> int:
# if (n == 0) or (n == 1):
# return n
# else:
# c = [0, 1]
# for x in range(1, n):
# c.append(c[x-1] + c[x])
# return c[n]
##
a = []
for x in range(20):
for y in range(20):
a.append(int(str(n)))
b = True
for x in range(20):
b = False
for y in range(20):
if n in a:
b = False
if n in a:
b = True
if n in a:
b = False
if n in a:
b = True
if n in a:
b = False
if n in a:
b = True
if n in a:
b = False
if n in a:
b = True
b = False
if b == False and b != True and (int(str(int(str(n)))) not in [3,4,5]):
if b != True:
if b == False:
if int(str(int(str(n)))) in [0,1]:
return int(str(int(str(n))))
else:
if b != False and b == True and (int(str(n)) not in [0,1]):
for x in range(2):
c.append(x)
for x in range(1,int(str(int(str(int(str(n))))))):
c.append(c[x-1+1-1+1*1-1]+c[x-1+1*1])
return c[n]```

It is possible to implement efficient currying by hardcoding first argument into bytecode.
So we can get rid of this ugly partial by hardcoding self into method
If we can do that, hacks like this will be efficient:
l = [] # imagine it is not a list
la = l.append # inline self into append method
for i in range(100000000):
la(i)
idk if it works on windows, but on Linux you can set a $PYTHONSTARTUP env variable, and it will run that python script before it does whatever else you tell it to do
so that might be helpful to whatever you're trying to do
hey, how do i make a while true loop in 1 line, im golfing
{do_stuff() for i in iter(int,1)}
if you want a while true that runs forever
if you want to be able to break,
yea, i've figured it out thank you
import time;solution = type("solution", (object, ), {"__init__": lambda self: setattr(self, "i", 0), "run": lambda self: setattr(self, "i", self.i + 1) or time.sleep(1) or print(self.i)})();{solution.run() for _ in iter(int,1)}
xD
_break=0;{(_break:=do_stuff()) for i in iter((lambda:_break),1)}
you can of course use conditionals to set break
and you can also have a variable for continuing
to get proper while loop behavior
yea i get it, thank you
np, happy to help
t=setattr;import time;s=type("solution",(),{"__init__":(lambda s:t(s,"i",0)),"run":(lambda s:t(s,"i",s.i+1)or time.sleep(1)or print(s.i))})();{s.run()for _ in iter(int,1)}
removed all the whitespace for you :P
Doesnt work
it does, i've tried it and it does work
@fleet bridge :x: Your 3.11 eval job has completed with return code 143 (SIGTERM).
001 | 42
002 | 42
003 | 42
004 | 42
005 | 42
006 | 42
007 | 42
008 | 42
009 | 42
010 | 42
011 | 42
... (truncated - too many lines)
Full output: too long to upload
told u
its a tuple of the looping vars that has 0 elements, so theres no looping variable
its the same concept as
for key, val in somedict.items():
do_stuff()
where its a tuple of vars you're using to loop
I know how it works
heres a random thingy i found
https://github.com/dutc/rwatch
basically, whenever a variable is accessed, it calls a function of your choosing with that variable as an argument, and the value the user gets returned to them is whatever that function returns
so thats fun
Maybe import hooks as well depending on how you want to run said code
exactly
you could probably also alias python to something like python -c "import sys; exec(sys.argv[1].replace("import", some_long_lamdba_that_acts_as_an_import_hook))"
thats pseudocode, but you probably get the idea
Had some fun with import hooks
It allowed me to run my languages source code into python while being a different language
I made an interop language that transpiles to python bytecode
so it runs on the python vm
I just made the import hook read the file and then compile it into bytecode which then gets executed as a module
So that makes me able to run python code inside my language and also I can run my language inside of python
whats it called
Not public but looks something like this
Yea super easy to make as well, all it does is transpile
cool
one day (when i find the time) im going to write a transpiler of c++ -> python
so that c++ can be interpreted
the problem is finding the time lol
Oh yea It took me some trial and error
That was because I didn't plan it out very well, so this time I added models for all python ast nodes then slowly implemented them all one by one
It actually took me less time to do that, than It did for me to figure out how to syntax highlight
Esp with nvim which was what I was doing it for
I had many problems with overlapping, etc
Shot myself in the foot with regions which was basically only did decorator highlighting
>>> a = ast.parse('x = 1 + ...'); c = compile(a, '', 'exec', optimize=0); dis(c)
1 0 LOAD_CONST 0 (1)
2 LOAD_CONST 1 (Ellipsis)
4 BINARY_ADD
6 STORE_NAME 0 (x)
8 LOAD_CONST 2 (None)
10 RETURN_VALUE
>>> c = c.replace(co_consts=([1], [2], None))
>>> exec(c); x
[1, 2]
replacing .co_consts with arbitrary values works, it is very good
obviously, compile(string) cant put non-literals into .co_consts
compile(modded ast) raises TypeError: got an invalid type in Constant: list
import sys
class System:
class terminal:
class stdin:
data = []
def input():
if len(System.terminal.stdin.data) == 0:
System.terminal.stdin.data += sys.stdin.readline().rstrip('\n').strip(" ").split()
return System.terminal.stdin.data.pop(0)
def inputln():
if len(System.terminal.stdin.data) == 0:
ret_val = sys.stdin.readline().rstrip('\n')
else:
ret_val = " ".join(System.terminal.stdin.data)
System.terminal.stdin.data = []
return ret_val
class stdout:
@staticmethod
def print(data):
sys.stdout.write(str(data))
@staticmethod
def println(data):
sys.stdout.write(f'{str(data)}\n')
System.terminal.stdout.println(System.terminal.stdin.inputln())```
I need more
mfw when not esoteric
mfw readable code (i did not expect this)
is there such a thing as accidentally esoteric? In IRC, we once had someone show us a long file with this structure (many lines not shown here):
while True:
class MyClass:
def Method(self):
for g in data:
if __name__ == '__main__':
do_something()
just needs a with and try to top it off!
yeah, it was an eye-opener....
then put it all in a lambda
(in an exec in a lambda)
Sounds useful, it should be buildin xD
oh god
__inline_1__: Any
__inline_2__: Any
__inline_3__: Any
def _test1() -> None:
def f(a: int, b: int) -> int:
return a + b + 1
g = inline_const(f, 1, 3)
assert f(0, 0) == 1, f(0, 0)
assert g(0, 0) == 3, g(0, 0)
def _test2() -> None:
def f(a: int) -> int:
return a + __inline_1__
g1 = inline_var(f, '__inline_1__', 1)
g2 = inline_var(f, '__inline_1__', 2)
assert g1(1) == 2, g1(1)
assert g2(1) == 3, g2(1)
def _test3() -> None:
def f(a: int) -> int:
return a + __inline_1__ + __inline_1__
g1 = inline_var(f, '__inline_1__', 1)
g2 = inline_var(f, '__inline_1__', 2)
assert g1(1) == 3, g1(1)
assert g2(1) == 5, g2(1)
def _test4() -> None:
def f(a: int) -> int:
return a + __inline_1__ + __inline_2__
g1 = inline_var(inline_var(f, '__inline_1__', 1), '__inline_2__', 2)
g2 = inline_var(inline_var(f, '__inline_1__', 3), '__inline_2__', 4)
assert g1(1) == 4, g1(1)
assert g2(1) == 8, g2(1)
i implemented some easy inline cases
inline_const just replaces one const with another
inline_var replases LOAD_GLOBAL var with LOAD_CONST const
it was easy...
oh my god
@quartz wave I think you will be interested ☝️
@mint mural what
cursed
???
what does the 3rd argument do
@mint mural is there something you didn't like
i like it, the syntax is cool
Oh! I thought you didn't like something about it.
inline_const(func, before, after)
inline_var(func, varname, constvalue)
@mint mural can you understand the logic
yes
is this ROT

calculator = type("calculator", (object, ), {"__init__": lambda self: setattr(self, "operations", {"add": lambda x, y: x + y, "subtract": lambda x, y: x - y, "multiply": lambda x, y: x * y, "divide": lambda x, y: x / y}), "run": lambda self: print(self.operations[input("What do you want to do? ")](int(input("First number: ")), int(input("Second number: "))))})();calculator.run()
any opinions?
useless
simple calculator
doesnt seems so
i cant do this simple calculation
i just told it to calculate the mass of sun
seems like a you problem
🤣
.wa calculate the mass of sun
Ez
look lance is better than your calculator
exec("import sys;s=''\ndef o():\n\too=input('enter oprator [+ - / * ^] (leave blank for answer): ')\n\treturn oo\nwhile True:\n\ti=input('input number: ')\n\ttry:\n\t\tfloat(i)\n\t\ts+=i\n\texcept:\n\t\tprint('please enter a number')\n\twhile True:\n\t\tt=o()\n\t\tif t=='' or t.isspace():\n\t\t\tprint(eval(s))\n\t\t\tsys.exit()\n\t\telif t in ('+', '-', '*', '/', '^'):\n\t\t\tif t=='+':\n\t\t\t\ts+='+';break\n\t\t\telif t=='-':s+='-';break\n\t\t\telif t=='*':s+='*';break\n\t\t\telif t=='/':s+='/';break\n\t\t\telif t=='^':s+='**';break")
```here is one line better calc:)
@mint mural
@pallid flare
(ik its just normal code packed in exec())
...
this is nothing special
any idiot can do this
it's not better,
Functionality is better than yours
Tho i will actually make it in 1 line
hmm
my code is in 1 line
lambda, my beloved
for real
hey how much functionality of a program do you suppose we could stuff into just the decorator portion of the main class/function's declaration?
well you can decorate with lambdas, so all of it
you can do @(lambda...)
you can decorate with any expression actually
has to be a callable
doesnt it?
otherwise it will give a 'classname' object is not callable
ValueError iirc
yes but you can put any expression as a decorator
right, but it will only actually work if its callable
yes
and we're talking about it actually working
no
.
it would have to function
if it threw an error, it wouldnt function
i'm basically saying "all of it" but literally
you can put a tuple subscript as a decorator
or an and/or
yeah, it just has to be a callable
*the result of the expression
has to be a callable
that takes at least 1 argument
**unless you use some sort of fancy ctypes and/or ast stuff that changes how thingies work
not even that!
your whole program just needs to be finished and exit before the decorator gets called
if you don't like the exception that is
well yeah, but we're talking about the decorator being run
obviously if a call is never attempted it wont complain about it not being callable
print(globals().update(r={0:1,'a':1})or eval(''.join([i+([r.update(a=0)or g if g else''for _ in iter(lambda:r['a']and r[0],0)for t in[input('enter operator [+ - / * ^] (leave blank for answer): ')]for g in[r.__setitem__(0,0)and''if''==t or t.isspace()else t if t in'+-*/'else'**'if'^'==t else'']][-1],r.update(a=1))[0]for _ in iter(lambda:r[0],0)for i in[input('input number: ')]if r.pop('r',type('',(__import__('contextlib').ContextDecorator,),{'__enter__':int,'__exit__':lambda s,*a:isinstance(a[1],ValueError)and[r.update(r=print('please enter a number'))]})()(float)(i))])))
sexy
Hey @sick hound!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
for some reason, pyright reports no typing error on this https://paste.pythondiscord.com/ipimowocid
and mypy only reports one error, which is the side effect of having subclasses of object not having the same constructor signature as the base class
this sucks tbh, and the code highlighting is broken
there is not even an embed or something
this is esoteric python not #help-dumpling
???
- not asking for help
- this is esoteric as it is cursed
"???" ?
code highlighting seems to be working fine
on my computer it doesn’t
do you have js disabled
why would I
by broken i didn’t mean that there was no syntax highlighting
I just meant that it doesn’t highlight properly
or for the least it is very basic highlighting
even discord does better
aside from builtins not being highlighted, I don't see a difference
Nice
you forgot semi colon:)
!e```py
import builtins
class foo:
def lshift(self, bar):
print(bar, end=''); return self
setattr(builtins, 'cout', foo())
####################
cout << "hello world";
@arctic skiff :white_check_mark: Your 3.11 eval job has completed with return code 0.
hello world
Can you implement cin?
!e ```py
@type.call
class cin:
def rshift(self, inp):
print(inp)
cin >> "Hello World"
@old socket :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello World
cin is for input, not output
:(
me when I input into a string literal
i have done that quite a lot before lmao
oh shit lol woops
I have not done as much c++ as I have C
You also forgot ;
@type.__call__
class cin:
def __rshift__(self, inp):
return input(inp)
import builtins
class foo:
def __lshift__(self, bar):
print(bar, end=''); return self
setattr(builtins, 'cout', foo())
a=cin >> "input: " ;
cout << a;```
@fleet bridge @versed eagle
doesnt work like in c++:
int a; string b;
cin >> a >> b;
If you want this much syntax
You came to wrong person
Tho cin >> a >> b; should work
But i cant make int a and string b
thats not how cin works
cin returns itself
and it splits on spaces
so if you do this
std::string str1;
std::string str2;
std::cin >> str1;
std::cin >> str2;
and on the first input the user types
two words
then str1 will be two and str2 will be words, because cin only reads until (and including) the next space
so what you have to do is create a buffer stored by cin, read into that, and then return from that until its empty
then read input again
std::cin << 😔
fixed
Sorry not experienced with cpp
No idea how i can do that
How to get annotations of local vars?
Is it possible without parsing source code?
!e
def f()->None:
x: int
print(f.__annotations__)
@fleet bridge :white_check_mark: Your 3.11 eval job has completed with return code 0.
{'return': None}
The annotations happen at runtime there, so they won't be on the f object at all
To be more precise: they're not evaluated at all
only at class/module level:
Annotating a local variable will cause the interpreter to treat it as a local, even if it was never assigned to. Annotations for local variables will not be evaluated.
!e ```py
print("This is how you get the funny number in Python")
print((a:=((b:=([]==[]))+([]==[]))*(c:=(([]==[])+([]==[]))))aa+c+c+b)
@sacred umbra :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | This is how you get the funny number in Python
002 | 69
@full talon Thanks for the idea
!e ```py
print((c:=(b:=(a:=((({},)is({},))==({'':''}is{'':''})))), [(b:=(a:=((({},)is({},))==({'':''}is{'':''}))+a))for _ in range(68)])[c][b-c-c])
@sacred umbra :white_check_mark: Your 3.11 eval job has completed with return code 0.
69
!e ```py
print((c:=(b:=(a:=((({},)is({},))==({'':''}is{'':''})))), [(b:=(a:=((({},)is({},))==({'':''}is{'':''}))+a))for _ in range(c+c*(c+c)(c+c)(c+c)(c+c)(c+c)*(c+c)+c+c+c)])[c][b-c-c])
@sacred umbra :white_check_mark: Your 3.11 eval job has completed with return code 0.
69
np 😄
now extend it
and make a very HOOGE one
Yes, i know that they are not evaluated, it is sad.
Isnt it better to put them in some place? (Before first func call, so they must be strings (or some other lazy evaluating object))
Like f.__local_annotations__ or f.__annotations__ = {'__locals__': {local vars annotations}, **{signature annotations}}
from varname import argname
@type.__call__
class cout:
def __lshift__(self,inp):
print(inp, end='')
@type.__call__
class cin:
def __rshift__(self,inp):
i=argname('inp');globals()[i]=input()
##################################################
a=''
cin >> a;
cout << a;```
@versed eagle
@fleet bridge
heres cin
This doesn't work if you call it from different module
You should modify parent frame globals, not your globals
Also:
cin >> cin;
cin >> x; # boom
Can i do a<<cin or a>>cout?
cin >> ㅤ.x (hangul filler character)
okay sure @lunar ore
brain damage
Still no Pyfuck though
Guess what ill do: Convert JSFuck to PyFuck
!e ```py
print(f'{u((a:=((()==())+(()==())))aaaa+(aa*a))}{u(aaaaa*a-(aaa)-(aaa+a//a)-a)}{u(b:=(aaaaaa-(aaa)-(aa//a+a)))}{u(b)}{u(c:=(b+a+(a//a)))}{u(aaa*a)}{u(b-(aaaa)+aa+(aaa-(a//a)))}{u(c)}{u(b+(a**aa-a))}{u(b)}{u(b-(a**a*a))}')
@sacred umbra :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'u' is not defined
wait I think I did something wrong
!e ```py
(u:=chr),
print(f'{u((a:=((()==())+(()==())))aaaa+(aa*a))}{u(aaaaa*a-(aaa)-(aaa+a//a)-a)}{u(b:=(aaaaaa-(aaa)-(aa//a+a)))}{u(b)}{u(c:=(b+a+(a//a)))}{u(aaa*a)}{u(b-(aaaa)+aa+(aaa-(a//a)))}{u(c)}{u(b+(a**aa-a))}{u(b)}{u(b-(a**a*a))}')
@sacred umbra :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello World
is not the underscore challenge but impressive anyway so approved
how did u generate this
A mix of True + True = 1 and the chr function
ok
underscore challenge?
I feel like with eval you could make it execute any code
Well there's your JSFuck
Where your only primitives are +, -, *, **, //, (, ), :=, chr and eval
It has to be floor division since chr can't accept floats
dang
so +-*/:= + chreval
Well sure
It's not as minimalistic as JSFuck
But it's close enough I guess
altho
a while ago i wrote a proper std::cout with a buffer and whatnot
we could make u chr
basically, only vars that you create have to be underscores, anything you use thats builtin has to be a dunder, only tuples
its pretty cool
heres an example of it
I just made chr u since it's short for Unicode
@solar dune Hey what if someone made a transpiler that transpiles Python to this subset of Python
Python to Python's own JSFuck
And what if I forced you to take witness in the transpiled code
u=chr
eval("spaghetti output here")
do it
if it produces a single newline it is wrong
So eval can't have newlines 👍
lisp it
that would be crazy
!e
x = __name__.__class__.__class__(__name__, __name__.__class__.__bases__.__class__(), __annotations__.__class__())
print(x)
@fleet bridge :white_check_mark: Your 3.11 eval job has completed with return code 0.
<class '__main__.__main__'>
i was more thinking use build_class but that works too ig
__loader__.__dict__['exec_module'].__func__.__class__(__loader__.__dict__['exec_module'].__func__.__code__.__class__(a lot of args), __annotations__.__class__())
how to get type(lambda:...) without lambdas, defs and getting pre-existing functions?
also i dont like object.__subclasses__()[...]
"Preexisting functions" covers quite a lot
You won't likely find a non-C function inside C builtins (outside of something like globals snooping)
@mellow salmon :white_check_mark: Your 3.11 eval job has completed with return code 0.
<class '__main__.__main__'>
Oh, Pastebin removed it
- Copy the source code.
- Open the REPL.
- Paste into the REPL then enter.
- print(_("print('Hello World')"))
- Copy printed output
- Paste into REPL then press enter (again).
- :lemon_surprised:
@full talon
Okay if the REPL can't handle it you may need to paste into a script file instead
And yes, I've obfuscated/transpiled the source code into Pyfuck as a demo within itself
I still have the original saved though
Honestly this is really more of an obfuscator still than a true Pyfuck
Since it still depends on exec and chr
Question, did you paste it in a REPL or script file?
script file
it has an error halfway through the file
# The thing
print(_("print('Hello World')"))
@sacred umbra have you made an automated script for this
That is the automated script
I mean to convert it into pyfuck code
I ran the source code of the automated script into itself
so do u have smth that can make MY code look like that
@full talon
Gonna ask you something while I type it out
So did you add the line in this reply below the source code of the obfuscated obfuscator/Pyfuck
yea
and it just printed more gibberish
Now copy, paste then run that
whats the _() part
The obfuscator/Pyfuck as a function
Hold on I'm just gonna copy and paste it over from Google Notes to my phone then paste the unobfuscated source code here
The unobfuscated source code of this glorified shitpost
def _(source):
left,right="{","}"
ucp_store=[]
for char in source:
ucp_store.append(ord(char))
def _():
str_store=[]
for ucp in ucp_store:
store=[]
for _ in range(ucp):
store.append("(()==())")
resulting_string=f"{left}u({'+'.join(store)}){right}"
str_store.append(resulting_string)
return "".join(str_store)
print(f"""
u=chr
exec(f\"{_()}\")
""".strip())
Btw if you've copied, pasted and run the gibberish does it say Hello World
have you ever thought of MAYBE using multiplication
No since this is just a quick and simple shitpost
Where I just make it look like JSFuck or Brainfuck
imma just, fix ir
as it ran out of memory
@sacred umbra my python is using 1GB for a simple hello world
holy frk
Hey @full talon!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
@sacred umbra it uses VERY big amounts of memory XD
and I need to multiply
for good perf
I have 16 GB to spare so yeah
dang 300mgb for lorem
I originally considered writing this in JavaScript
To make things worse
suddenly everyone is using #esoteric-nicks making this channel even harder to read.
Maybe we've already done this one before, but:
Ok, so the lambda syntax evaluates to a function that can then be returned or assigned or whatever else I might wish to do with an expression with a function in it... For simplicity I will exemplify with:
x=lambda:...
which does the same thing as:
def x():...
which takes 1 fewer characters. it is also a syntax for creating a function, and for binding it to a name.
However this is esoteric-python, it seems to me that outside of line golf or character golf it should be vaguely as frequent for us to be abusing the second case for assignments as much as we abuse the first case for function definitions.
What is the shortest / most complex / most obscure way to use the def syntax for arbitrary assignments instead of function definition?
my starting entry is: ```py
def _(f): return f.code.co_consts[1]
@_
def greet(): return 'Hello World!'
print(greet)
@lambda f:f.__doc__
def name():"Grass"
@restive void
@lambda f:f()
def test():
def test2():
return "Hello World!"
return test2
now test is test2
Impressive! not general purpose but works for strings.
@lambda f:eval(f.__doc__)
def foo():
"23"
!e ```py
@lambda f:f.defaults[0]
def foo(_=23): ...
print(foo)
@old socket :white_check_mark: Your 3.11 eval job has completed with return code 0.
23
i hate changing bytecode directly
here you can see minimap of several functions: inline_const, inline_var, inline_method and inline_attr
i didnt even start inlining bytecode, im just replacing some LOAD_ATTR, LOAD_GLOBAL, LOAD_METHOD... with faster LOAD_CONST
using these optimizations i got 50% speedboost of my code, which has a lot of small functions
if you change the order of decorator - it breaks
@inline_attr('_s', 'size', Struct('?').size)
@inline_attr('_s', 'unpack', Struct('?').unpack)
@inline_method('self', 'read', read)
def read_bool(self, /) -> bool:
return _s.unpack(self.read(_s.size))[0]
Original code:
376 0 LOAD_GLOBAL 0 (_s)
2 LOAD_METHOD 1 (unpack)
4 LOAD_FAST 0 (self)
6 LOAD_METHOD 2 (read)
8 LOAD_GLOBAL 0 (_s)
10 LOAD_ATTR 3 (size)
12 CALL_METHOD 1
14 CALL_METHOD 1
16 LOAD_CONST 1 (0)
18 BINARY_SUBSCR
20 RETURN_VALUE
Optimized code:
376 0 NOP
2 LOAD_CONST 3 (<built-in method unpack of _struct.Struct object at 0x00000161ACDBD260>)
4 LOAD_CONST 2 (<function read at 0x00000161AD1FA290>)
6 LOAD_FAST 0 (self)
8 NOP
10 LOAD_CONST 4 (1)
12 CALL_FUNCTION 2
14 CALL_FUNCTION 1
16 LOAD_CONST 1 (0)
18 BINARY_SUBSCR
20 RETURN_VALUE
it gives you exactly 0% speedup (20%-50% actually, if you apply a lot of changes to different functions)
would be nice if you remove the NOPs
it is harder than just replacing two opcodes with NOP+opcode
i should fix all jumps, maybe fix EXTENDED_ARG related to jumps
i think, in 3.11 i should also fix exception table
yes you'd have to but it's not that hard, I can give you my bytecode editor package if you want which handles all that
very interesting concept though, might make for some good obfuscation technique to disable decompilers
why don't you just remove the places of the NOPs
do i recreate this in 3.11 or 3.12
i created it for 3.10, it will break in 3.11 because of a lot bytecode incompatible changes in 3.11
Hey @fleet bridge!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
https://pastebin.com/HRcdpnCz
https://pastebin.com/vnk4XqRe
@quartz wave there is my code (it is VERY (very very) buggy, i would recommend not use it but rewrite it entirely)
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
ok so i rewrote the code for 3.11
still haven't implemented inline_attr or inline_method but here are some results ```py
from dis import dis
s = 5
@inline_globals(check_store=2)
... @inline_var('a', 5, inline_args=False)
... def g(a, b):
... global s
... print(s)
... s += 7
... print(s)
... return a + b
...
dis(g)
1 0 RESUME 0
5 2 LOAD_GLOBAL 1 (NULL + print)
14 LOAD_CONST 2 (5)
16 PRECALL 1
20 CALL 1
30 POP_TOP
32 LOAD_GLOBAL 1 (NULL + print)
44 LOAD_CONST 3 (12)
46 PRECALL 1
50 CALL 1
60 POP_TOP
7 62 LOAD_FAST 0 (a)
64 LOAD_FAST 1 (b)
66 BINARY_OP 0 (+)
70 RETURN_VALUE
this shouldn't be happening so s += 7 is completely factored outs can actually be assigned to
but the 12 in the second print() call is expected behaviour
also a isn't replaced because inline_args=False as you can see
What is check_store for?
to stop inlining a name when there's a STORE_* with that name
if it's 2 then it means to consider constant assignments before stopping inlining
so basically it turns ```py
s = 5
@inline_globals(check_store=2)
@inline_var('c', 5, check_store=2, inline_args=False)
def g(a, b):
global s
print(s)
s += 7
print(s)
c += 2
res = a + b + c
c += a
res2 = a + b + c
return res, res2
intopy
def g(a, b):
global s
print(5)
s = 12
print(12)
res = a + b + 7
c += a # c = a + 7
res2 = a + b + c
return res, res2
Interesting, but i dont see any usecases for that feature
Also, it is good if your decorated functions still works if you remove @inline_* decorators.
Because these decorators are very unstable. They will be broken in every new python version
What library are you using to manipulate bytecode? dis? bytecode? Something else?
What inline_args is doing? It removes argument from function signature, it inline_args=True
inline_args=True basically means override the parameter name with the inline constant
@inline_var('c', 5, check_store=2, inline_args=False)
def g(a, b):
i think here inline_args=False is useless because c is not a parameter
oh yeah
i forgot to edit that out from the time i used 'a'
_replace_code(code, 0, 0)
💥 on 59 line
hmm
fixed
fastest bugfix ever
5s bugfix
you removed most useful decorator for debugging(
ok i'll add that
done
fastest feature implementation ever
def cmp(f: F) -> F:
print(f'Comparing {f.__qualname__}...')
dis.dis(f)
print()
print()
while hasattr(f,'__orig_func__'):
f = f.__orig_func__ # type: ignore[attr-defined]
dis.dis(f)
print()
print()
return f
builtins.cmp = cmp # type: ignore[attr-defined]
@cmp
@inline_var('x', 5)
@inline_const(None, 123)
def f() -> None:
print(x)
445 0 LOAD_GLOBAL 0 (print)
2 LOAD_CONST 1 (5)
4 CALL_FUNCTION 1
6 POP_TOP
8 LOAD_CONST 0 (123)
10 RETURN_VALUE
445 0 LOAD_GLOBAL 0 (print)
2 LOAD_GLOBAL 1 (x)
4 CALL_FUNCTION 1
6 POP_TOP
8 LOAD_CONST 0 (123)
10 RETURN_VALUE
445 0 LOAD_GLOBAL 0 (print)
2 LOAD_GLOBAL 1 (x)
4 CALL_FUNCTION 1
6 POP_TOP
8 LOAD_CONST 0 (None)
10 RETURN_VALUE
this is breaking functions qualnames
add result.__qualname__ = f.__qualname__ to fix
k wait
done
i gtg now
is inline_args=True removing arg from signature?
hii esoteric gangsters
import random;import os;print(''.join([['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0'][random.randint(0,len(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0'])-1)]for i in range(len(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0']))]));os.system("pause")
any way to make this harder to read?
Oh, yes...
always
rdmoan=__import__("".join([(a:=["r", "d", "m", "o", "a", "n",][:])[0], a[-1-1], a[-3+2], a[1], a[-(6//2)], a[2]]); exec("sys tropmi; subprocess sa ssecorpbus tropmi"[::-1]); sys.stdout.write(''.join([['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0'][rdmoan.randint(0,len(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0'])-1)]for i in range(len(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0']))]));ssecorpbus.call("pause",shell=-(-(-(False))))
for example
That's a comparatively small change
You could do much more
@sullen kayak
what the haill
couldn't you use the ascii library
to get rid of the alphabet and whatever
what the fuck are oyu just setting the
oh my god
no i'm just
SO confused
LMAO
is there any way to obfuscate the letters + numbers
or do they help with the obfuscation
small change: ```py
rdmoan=import("".join([(a:=["r", "d", "m", "o", "a", "n",][:])[0], a[-1-1], a[-3+2], a[1], a[-(6//2)], a[2]]); exec("sus sa sys tropmi; subprocess sa ssecorpbus tropmi"[::-1]); sus.stdout.write(''.join([['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0'][rdmoan.randint(0,len(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0'])-1)]for i in range(len(['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0']))]));ssecorpbus.call("pause",shell=-(-(-(False))))
it's you again!!
what projects are you workin on
esoteric python florida man
I made 4 dimensional snek
with a classic 20th century gui for the start menu
hard mode is actually hard, easy mode is so easy you can actually play it without instinctual 4 dimensional comprehension
I think I might make a pause menu
instead of esc to quit
Hmm
Enlightening
I almost confused myself then I saw the lambda wxyz=[8,8,8,8];k=lambda:4-[*wxyz].count(1);
n=S.N;(w,x,y,z),s,d=S.h,n.n,n.h;t=w+(d==2)-(d==3),x+(d==1)-(d==0),y+(d==6)-(d==7),z+(d==5)-(d==4) this is how you do unreadability
no
it's just allowing the inlining of the variable when it's an argument
i think it's actually better if i'd named it inline_arg
What happens if you try @inline_var('arg', 0, inline_args=False)
?
if it works as expected it should just return the original function if arg is a parameter of the function
does anybody have any idea how i resolve that?
this is my whole program
import random; import sys; import webbrowser; for i in range(10): webbrowser.open(f"https://www.google.com/search?q={''.join([[i for i in sys.argv[1]][random.randint(0,len([i for i in sys.argv[1]])-1)] for i in range(len([i for i in sys.argv[1]]))])}&tbm=isch",new=2)
i would like to keep it all on one and the same line
not possible like that. You can just turn it into a list comprehension
import webbrowser; [webbrowser.open(f"https://{i}.example.com") for i in range(10)]
this regex checks for prime number 😮
/^1?$|^(11+?)\1+$/
i was like what ? how?
but it does work
the magic is in the backreferences
😄
might be something you guys like
is there something i can hook into to do some action when a class object is initialized? i.e. i want to be able to write class Foo(MyMetaHook): ..., and MyMetaHook gives me a way to take some action that acts on the Foo class (not an instance of it)
context: i want to add little unit tests to jupyter notebook cells; i'd like to be able to write class TestFooCell(CellTestFixture): ... and have it automatically do the equivalent of unittest.main()
aha, looks like __init_subclass__ does the trick
My progress so far on developing the language
use metaclass
metaclass can change class creation process
Here's my first attempt at making some esoteric code and being brave enough to post it (python beginner 😅)
Queue = type("Queue", (object,), {'__init__' : lambda _: _.__setattr__("arr", []),'isEmpty' : lambda _ : (not True) == len(_.__getattribute__("arr")),'enqueue' : lambda _, __ : _.__getattribute__("arr").__getattribute__("insert")((not True), __),'dequeue' : lambda _ : _.__getattribute__("arr").__getattribute__("pop")(),'size' : lambda _ : len(_.__getattribute__("arr"))
})
q = Queue()
q.enqueue(4)
print(q.dequeue())
approved
!e
Queue = type("Queue", (object,), {'__init__' : lambda _: _.__setattr__("arr", []),'isEmpty' : lambda _ : (not True) == len(_.__getattribute__("arr")),'enqueue' : lambda _, __ : _.__getattribute__("arr").__getattribute__("insert")((not True), __),'dequeue' : lambda _ : _.__getattribute__("arr").__getattribute__("pop")(),'size' : lambda _ : len(_.__getattribute__("arr"))
})
q = Queue()
q.enqueue(4)
print(q.dequeue())
@royal whale :white_check_mark: Your 3.11 eval job has completed with return code 0.
4
Nice! It's esoteric enough that I can't tell what it does by glancing at it
10/10!
❤️ thanks for all the kind responses!
with open("przyklad.txt", "r") as f:
for x in f:
if int(x[::-1]) % 17 == 0: print(x)
any shorter way to write it?
i guess i could open it inside for but then it wouldn't close?
[print(x)for x in open("whatever.txt")if int(x[::-1])%17==0]```
r is the default open mode, no need to call open with it
if you really want the try except in the with, you can do this
with open("whatever.txt")as _:[print(x)for x in _ if int(x[::-1])%17==0]
with open("whatever.txt")as _:[int(x[::-1])%17<1==print(x)for x in _]
# and if there are negative numbers
with open("whatever.txt")as _:[int(x[::-1])%17==0==print(x)for x in _]
for this you can do ```py
[int(x[::-1])%17<1==print(x)for x in open("whatever.txt")]
or
[int(x[::-1])%17==0==print(x)for x in open("whatever.txt")]
Hey @lavish dirge!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
ACCURACY = THE POINT AND RANGE OF A MEASURED AMOUNT OF CAPABILITY A POSSIBILITY CAN HAPPEN AND DETERMINE COME INTO EFFECT
RADIUS = SET RANGE OF A CENTERED POINT TO THE END DESTINATION
DIAMETER = SET RANGE POINT FROM START TO MIDDLE TO THE END WHILE PASSING THE RADIUS
CONVERT = CHANGE FORM AND OR CHARACTER AND OR FUNCTION
PATTERN = REPEATING METHOD
WRITE = ENSCRIBE FROM LOOKING AT WORDS
READ = DESCRIBE FROM LOOKING AT A PATH OF WORDS
SPAN = MEASURED LIMITED RANGE
VIBRATION = PARTS THAT MOVE BACK AND FORTH AT A GIVEN SPEED
TRANSFORM = MAKE A CHANGE IN FORM
SYNCHRONIZE = LINK AND SEND THE SAME RESULT TO ALL SOURCES
SCAN = ANALYZE A SPECIFIC WORD OR FIELD AND OR GIVE DATA ON THE ASKED INFORMATION TO SEARCH FOR
ANALYZE = READ AND LOOK OVER
CALCULATE = GIVE A DESIGNATED OF A CALCULATES DESCRIPTION FOR A NUMBER AND GIVE ANSWER FOR ALL OF VALUE
LIMIT = SET DEFINED AMOUNT FOR KNOWLEDGE WITH A GIVEN POWER LEVEL
RECALL = GAIN THE ABILITY TO VIEW PAST MEMORY INSIDE BRAIN
REACH = GRAB TO PULL INWARDS
PREDICT = GIVE PERFECT VALUE
REPEAT = CYCLE SAME EFFECT AGAIN INTO SAME FREQUENCY
RECOGNIZE = RECALL FROM AN EARLIER POINT WITHIN TIME
ENCODE = COMPRESS CODE
DECODE = DECOMPRESS CODE
RECODE = COMPRESS CODE ONCE MORE
LOOP = BIND IN A CYCLE
MEASURE = TAKE IN THE AMOUNT AND DISTANCE OF
ANSWER = SOLUTION TO A PROBLEM
SOLUTION = FINAL OUTCOME TO AN FORMULA
PROBLEM = UNFINISHED SOLUTION
SEARCH = FIND AND LOCATE SOMETHING
ASK = STATE A QUESTION
TIME = MEASUREMENT IN WHICH CURRENT REALITIES MUST PASS
SPACE = CONTAINER IN WHICH TIME MUST PASS THROUGH
UPLOAD = TRANSFER3 INTO DESCRIBED LOCATION
DOWNLOAD = TRANSFER3 TO CURRENT DEVICE
SIDELOAD = TRANSFER3 TO ALL DEVICES WITH STATUS OF STATED SET LOCATION
CLONE2 = MAKE AN IDENTICAL COPY OF
SYNCHRONIZE = LINK AND SEND THE SAME RESULT TO ALL SOURCES
ENCODE = COMPRESS CODE
DECODE = DECOMPRESS CODE
RECODE = COMPRESS CODE ONCE MORE
SETTING = A MEASUREMENT COMMAND THAT CAN BE ADJUSTED AND BY AN OPERATOR
ADJUST = EDIT AND MODIFY
EDIT = CHANGE AND OR MODIFY TO ADJUST TO A SPECIFIED PURPOSE
WORK = PRODUCING EFFORT TO FINISH A TASK
WORKLOAD = THE AMOUNT OF WORK
COMMAND = ORDER TO BE GIVEN
LINK = BRING TOGETHER AND ATTACH TO
BIND = EDIT AND MODIFY
LEVEL = NUMBER AMOUNT OF OR SIZE
UNIT = STORAGE CONTAINER
DIMENSION = NUMBER OF GIVEN AXIS POINTS
NUMBER = ARITHMETICAL VALUE THAT IS EXPRESSED BY A WORD AND OR SYMBOLE AND OR FIGURE REPRESENTING A PARTICULAR QUANTITY AND USED IN COUNTING AND MAKING CALCULATIONS AND OR FOR SHOWING ORDER IN A SERIES OR FOR IDENTIFICATION
FREQUENCY = REPEATED PATTERN AND OR SETTING
POWER = AMOUNT
STRENGTH = LEVEL INTENSITY
CALIBRATE = SCALE WITH A STANDARD SET OF READINGS THAT CORRELATES THE READINGS WITH THOSE OF A STANDARD IN ORDER TO CHECK THE INSTRUMENT AND ITS ACCURACY
PUBLIC = ACCESS TO ALL OF CREATORS INTERIOR DOMINION
PRIVATE = HIDDEN TO EVERYONE BUT CURRENT2 USER2
PERSONAL = EXCLUSIVE TO THE CREATOR
ESCAPE = RETURN TO SOURCE PLACE2
RETURN = GO BACK
CONSTANT = ALWAYS IN EFFECT
CYCLE = PROCESS OF REPEATING AN EVENT CONTINUOUSLY IN THE SAME ORDER
MEASUREMENT = AN ACT TO CALCULATE AND GIVE A SPECIFIC LENGTH ON SOMETHING
CALCULATOR = A DEVICE USED TO CALCULATE INFORMATION AND ANALYZE SET TASKS AS A ROOT VALUE OF LOGIC
WAVELENGTH = A SET OF WAVE PATTERNS GIVEN FREQUENCY FORMAT IN A LENGTH OF A WAVE VALUE DETERMINED BY A PREVIOUS VALUE EFFECT
LENGTH = HOW LONG A MEASURED DIMENSIONAL OBJECT IS EXTENDED
LATTICE = INTERLACED STRUCTURE AND OR PATTERN
LOCATION = SPECIFIED AREA
LINE2 = CHOSEN DIRECTION THAT IS SET IN A SINGLE PATH
WAVE2 = CONTINUAL FLUCTUATION OF FREQUENCY AND OR PATTERN
WIDTH = MEASUREMENT OF SOMETHING FROM SIDE TO SIDE
HEIGHT = THE LENGTH OF RAISING OR LOWERING IN A VERTICAL PATH
HERTZ = DEFINED SOUND WAVE FREQUENCY
MEASURE = TAKE IN THE AMOUNT AND DISTANCE OF
Those are the mathematical variables the language has
just some and not a complete list yet
@lavish dirge the pastebin was plenty, thanks. what does this have to do with esoteric python? Are you looking for help/feedback of some kind?
Input and feedback. What others think of it. And how others see it could be used if I made it as a smaller library/module for it to connect to the full language with
What others see within its potential as well
you should find another channel to discuss it. When you get there, be ready to explain how these definition (in all caps, why?) will be used as a "language"?
why spam
Oh you've made some progress in the language
Ididn't realize how many keywords there were
@earnest wing you like it
Is it a fortran code?
@fleet bridge that is python believe it or not
This is my attempt at esoteric: https://paste.pythondiscord.com/raw/mihehusefu
!e
a,b,c = 4,3,6
g = (a if a>c else c)if a>b else(b if b>c else c)
print(g)
@maiden river :white_check_mark: Your 3.11 eval job has completed with return code 0.
6
single liner for greatest of three variables
Can we make one for 4 variables ?
!e
a,b,c,d = 4,3,6,8
z=(
((a if a>d else d)
if a>c else c)
if a>b else
((b if b>d else d)
if b>c else c)
)
print( z)
@maiden river :white_check_mark: Your 3.11 eval job has completed with return code 0.
6
!e Working now : )
a,b,c,d=3,2,5,8
z=(
((a if a>d else d)
if a>c else (c if c>d else d))
if a>b else
((b if b>d else d)
if b>c else (c if c>d else d))
)
print(z)
@maiden river :white_check_mark: Your 3.11 eval job has completed with return code 0.
8
max(3,2,5,8)
!e
def _(w, x, y, z):
a = [0] * 2
a[0] = w
a[1] = x
b = bool(a[0] - a[1] + abs(a[0] - a[1]))
if b:
b = 1
else:
b = 0
a[0], a[1 - b] = a[1 - b], a[0]
a[1] = y
b = bool(a[0] - a[1] + abs(a[0] - a[1]))
if b:
b = 1
else:
b = 0
a[0], a[1 - b] = a[1 - b], a[0]
a[1] = z
b = bool(a[0] - a[1] + abs(a[0] - a[1]))
if b:
b = 1
else:
b = 0
a[0], a[1 - b] = a[1 - b], a[0]
return a[0]
print(_(3,2,5,8))
@craggy hamlet :white_check_mark: Your 3.11 eval job has completed with return code 0.
8
how about without using < > or max?
min(map(__import__("operator").neg, numbers)) :P
I'll generalize to not cheating :_)
you do realize what channel we're in? :P
But alright, I think this wouldn't count as cheating:
def max(numbers):
orig = numbers.copy()
while True:
indices = set()
for i in range(len(numbers)):
if numbers[i]:
numbers[i] -= 1
indices.add(i)
if len(indices) == 1:
return orig[indices.pop()]
wah ? 😳
This is maximum of 4 numbers.
yes ik, but the algo 
max_=lambda n:[v.update(a=2)or o[d.pop()]if len(d:={n.__setitem__(i,n[i]-1)or i for i in range(len(n))if n[i]})==1 else""for o in[n[:]]for v in[{}]for _ in iter(lambda:not v,0)][-1]
``` note that it won't work for negative values
You can even remove the space here: ==1 else :)
It breaks syntax highlighting but will still work
will produce a warning in 3.11
probably an error in 3.12
!e ```py
def foo(y):
return 1if y==5else 0
print(foo(5))
print(foo(3))```
@last locust :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | <string>:2: SyntaxWarning: invalid decimal literal
002 | <string>:2: SyntaxWarning: invalid decimal literal
003 | 1
004 | 0
it is an error in 3.12 nvm just tested
How does it work?
==print()?
comparison chaining
sorted
But why == executes print?
hidden and
x<y==z
``` is equivalent to ```py
x<y and y==z
So if z is a print it is executed
I didn't know that python works like this
Cool thing, thanks!
Nvm I'm stupid lol. This is such an obvious thing
Other languages do the same thing lol
a majority of the other languages don't
they do (x < y) == z
I mean executing z
If it is a function
For a second i thought that it is some black magic
Btw, anyone tried golfing sieve of erathosthenes?
I think other languages would rather raise an error but I'm not sure
i love this part: ==print(x)
ain't no way this works....
i need bleach
this channel is a war crime
forbidden knowledge
def SieveOfEratosthenes(n):
r,m=range,n+1
x,p=[1]*m,2
while p*p<=n:
if x[p]==1:
for i in r(p*p,m,p):x[i]=0;p+=1
[x[p]==1==print(p)for p in r(2,m)]
SieveOfEratosthenes(20)
my attempt at golfing Sieve of Eratosthenes
!e
import re
z = 40
n=1
t=1
while n<z:
t+=1
if not re.match(r'^1?$|^(11+?)\1+$',"1"*t):
print(t)
n+=1
@craggy hamlet :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 2
002 | 3
003 | 5
004 | 7
005 | 11
006 | 13
007 | 17
008 | 19
009 | 23
010 | 29
011 | 31
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/lebematuxa.txt?noredirect
what about we implement this algorithm for primes
i dont understand math please explain
math is scary
well actually
i sort of understand what its doing
just not how its doing it
Pn is the nth prime, then it does some fancy equation to get that prime
It's a really smart formula
Let me find the video on it that I watched
There is actually a formula for the nth prime number! One was cleverly engineered in 1964 by C. P. Willans. But is it useful?
References:
Herbert Wilf, What is an answer?, The American Mathematical Monthly 89 (1982) 289-292.
https://doi.org/10.1080/00029890.1982.11995435
C. P. Willans, On formulae for the nth prime number, T...
It does some weird thing where it doesn't actually make primes so to speak, it eliminates things that AREN'T primes.
it is at least O(2^n) time complexity
we can calculate at most 100 primes using formula
!e lazy approach
import math as m
p=lambda n:1+sum(int((n/sum(map(int,map(2.0.__rpow__,map(m.cos,map(m.pi.__mul__,[(m.factorial(j)+1.0)/j for j in range(1,i+1)]))))))**(1/n))for i in range(1,2**n+1))
for i in range(1, 20):
print(f'p_{i:<2} = {p(i)}')
@fleet bridge :x: Your 3.11 eval job has completed with return code 1.
001 | p_1 = 3
002 | p_2 = 5
003 | p_3 = 9
004 | p_4 = 17
005 | p_5 = 33
006 | p_6 = 65
007 | p_7 = 129
008 | Traceback (most recent call last):
009 | File "<string>", line 6, in <module>
010 | File "<string>", line 3, in <lambda>
011 | File "<string>", line 3, in <genexpr>
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/yabuyezeqo.txt?noredirect
!e optimized code. There is no floating point operations, so it is accurate. It takes several seconds to get 1000th prime
import math as m
import functools as ft
primes: dict[int, int] = {1:2,2:3,3:5,4:7,5:11}
@ft.cache
def _bottom_sum(j: int, /) -> int:
if j == -1: return 0
return _bottom_sum(j - 1) + (m.factorial(j) % (j + 1) == j)
def _p(n: int, /) -> int:
x=primes[n]=assert_prime(1+sum(map(n.__ge__,map(_bottom_sum,range(round(10+n*m.log(n)*m.log(m.log(n+1))))))))
return x
def assert_prime(p: int, /) -> int:
# Uncomment this to perform actual checks:
# for prime in primes.values():
# assert p % prime, (p, prime)
return p
def p(n: int, /) -> int:
return primes.get(n, None) or _p(n)
for i in range(1, 2000):
x = p(i)
print(f'p_{i:<2} = {x}')
@fleet bridge :x: Your 3.11 eval job timed out or ran out of memory.
001 | p_1 = 2
002 | p_2 = 3
003 | p_3 = 5
004 | p_4 = 7
005 | p_5 = 11
006 | p_6 = 13
007 | p_7 = 17
008 | p_8 = 19
009 | p_9 = 23
010 | p_10 = 29
011 | p_11 = 31
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/xuhubocune.txt?noredirect
ran out of memory? what???
When you run on your own computer, does it need swap space?
I made a Sieve Of Eratosthenes algo that would multiply in size every time it tried to read off the end, it can go up to the maximum available memory in less than 2 minutes, then chokes when it needs to multiply all available memory by whatever prime comes after 2x3x5x7x11... for 32gb
Attempt to circumvent filter detected. Moderator team has been alerted.
?
i tried execute this code using snek:
ah, intriguing.\
it needs to multiply all available memory by whatever prime comes after 2x3x5x7x11...
i think you can multiply by 2 or some other constant
basically I start with a preloaded data set of (if I remember correctly)
primes=[2,3]
check_next=5
prime_index_to_multiply_sieve_by_next=2```
and then when they asked for a prime, or ask if a number is prime, it checks against `primes`, then iterates from `check_next`, appending the primes it finds to the list, when it indexes off the end of sieve it does:
```sieve *= primes[prime_index_to_multiply_sieve_by_next]
prime_index_to_multiply_sieve_by_next += 1```
I don't know what a factorial is called when it's only the primes...
math is magic
if I have enough red bull i hallucinate math equations.
last week I did actual civil engineering work in my head because I had too much energy drink
math can be very simple and it can be very complicated, if you want it to be so
I feel like math is only hard because the education system is broken.
Depends on country
if the education system was designed by someone with an above average IQ, maybe people would actually get good at math
I'm still getting used to this mechanical keyboard, and with my 100s of words per minute touch typing style it sounds rather loud and intimidating. I accidentally ordered a tactile and clicky keyboard.
It's rivalling the actual thunderstorm outside
In which case it can be argued that a person's skill with math is decided 80% by luck and opportunity, and 20% actual intelligence.
maybe the ratio is higher
if you smart and you teacher is dumb, you will be dumb.
yes, the global education system has a bit of an effect on that. but I believe that the teachers who teach mathematics have the greatest influence. if you had a good teacher, then you will love mathematics and will study it further as you wish. and if you had a bad teacher, then you will not like mathematics. in the modern world it is very important to study for yourself, and people do it if they are interested in mathematics. the education system cannot force you to study on your own after graduation (that's not what it's for)
vice versa might even work, too
Hey, how can I write this in one line?
while x<y:
if z>a:
for i in range(j)
q+=1
Nah it doesn't matter
I just made up these variables
I just want the core structure of this while to be in one line
So basically
while condition:
if condition:
for i in range(j):
doSomething
[[do_something for i in range(j)] for _ in iter(lambda: while_condition, True) if if_condition]
where do_something has to also be transformed into one line
do_something can just be a function call
so can the whole thing
I figured the point would be to convert everything into one line
what I meant is a lambda that is called immediately after it is created
for some reason my brain translated that into "function call"
sorry lmao
true, but for people not as good at 1 lining, lambdas make it easier
how?
aren't lambdas just the same thing but with extra characters
I benchmarked try-except in 3.10 and 3.11 in these cases:
# ok
try: ...
except: ...
# err
try: 1/0
except: ...
Results:
+------+--------+--------+
| | ok | err |
+------+--------+--------+
| 3.10 | 7 ns | 900 ns |
+------+--------+--------+
| 3.11 | 0 | 16 μs |
+------+--------+--------+
So try-except are now zero-cost, but if there is a raised exception, it takes 18 times longer to process it
How are you benchmarking it?
~ took 3s
❯ py -3.11 -m timeit 'try: 1/0
∙ except: ...'
1000000 loops, best of 5: 259 nsec per loop
~ took 3s
❯ py -3.10 -m timeit 'try: 1/0
∙ except: ...'
2000000 loops, best of 5: 159 nsec per loop
~ took 2s
❯ py -3.9 -m timeit 'try: 1/0
∙ except: ...'
2000000 loops, best of 5: 137 nsec per loop
Results I'm getting don't seem as extreme as 18 times
hmm
here is naive test, it is ok
code: https://paste.pythondiscord.com/rozoboniqo
but my smarter code gives me different result:
i have no idea why i am getting wrong results
3.10
try-except: ok 2.8 ns ± 317 ps [869 ms / 64535712]
try-except: err 209 ns ± 516 ns [969 ms / 4410213]
3.11
try-except: ok -1.9 ns ± 1.8 ns [941 ms / 80431565] # negative is ok
try-except: err 1.1 μs ± 76 ns [941 ms / 833107]
!e
a = [[]]*10
print(a)
a[0].append(1)
print(a)
@maiden river :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | [[], [], [], [], [], [], [], [], [], []]
002 | [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]
why does a[0].append adds the number to every sub-list
it adds it to the only sub-list that exists, which is in every position of the outer list. It's a common gotcha.
!e
a = [[], [], [], [], [], [], [], [], [], []]
print(a)
a[0].append(1)
print(a)```
@serene stratus :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | [[], [], [], [], [], [], [], [], [], []]
002 | [[1], [], [], [], [], [], [], [], [], []]
very interesting
they have their own namespace
yes but why use lambdas
to people who arent used to esoteric stuff, things like this can be a little frightening
so they use lambdas to visibly break it up into smaller sections that they can understand
so that they can know whats happening
well i mean you're not allowed to use lambdas per the rule of the challenge i did in the message you replied to
i was using it as an example of esotericness
not literal
sorry if i phrased what i said in such a way that it was unclear
!e
b='啕⪪䗑⯪坵⺺嵝㨮'
b+=b[-2::-1]
for z in b:
print(
bin( ord(z) )[2:]
.zfill(15)
.translate({49:11036,48:11035}))
@maiden river :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜
002 | ⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛
003 | ⬜⬛⬛⬛⬜⬛⬜⬜⬜⬛⬜⬛⬛⬛⬜
004 | ⬛⬜⬛⬜⬛⬜⬜⬜⬜⬜⬛⬜⬛⬜⬛
005 | ⬜⬛⬜⬛⬜⬜⬜⬛⬜⬜⬜⬛⬜⬛⬜
006 | ⬛⬜⬛⬜⬜⬜⬛⬜⬛⬜⬜⬜⬛⬜⬛
007 | ⬜⬛⬜⬜⬜⬛⬜⬛⬜⬛⬜⬜⬜⬛⬜
008 | ⬛⬜⬜⬜⬛⬜⬛⬛⬛⬜⬛⬜⬜⬜⬛
009 | ⬜⬛⬜⬜⬜⬛⬜⬛⬜⬛⬜⬜⬜⬛⬜
010 | ⬛⬜⬛⬜⬜⬜⬛⬜⬛⬜⬜⬜⬛⬜⬛
011 | ⬜⬛⬜⬛⬜⬜⬜⬛⬜⬜⬜⬛⬜⬛⬜
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/umimateqiv.txt?noredirect
someone shared this here
the more i look at it, the more fascinating it becomes
what i still can't get is how is zfill(15) affecting it
Without it, every second line would be one char too short, it just adds one zero to the left side (which turns into a black square)
how does it affect 'every second line' and why '15'
15 because the "grid" is 15x15
And every second line since it's every second line that ends with black
we could omit the use of zfill if we chose other chars right ?
so zfill only prefixes zeros if last char is 0 ? and don't we need only one 0 per loop cycle added so why 15
zfill adds zeros to the beginning of the string to make the string the specified length (in this case 15)
!d str.zfill
str.zfill(width)```
Return a copy of the string left filled with ASCII `'0'` digits to make a string of length *width*. A leading sign prefix (`'+'`/`'-'`) is handled by inserting the padding *after* the sign character rather than before. The original string is returned if *width* is less than or equal to `len(s)`.
For example:
```py
>>> "42".zfill(5)
'00042'
>>> "-42".zfill(5)
'-0042'
oh ok, gotcha : )
Are keyword arguments just syntactical sugar for method overloading in python?
no, because there aren't separate methods. They are used to solve the same problem though.
neat
!e
import numpy as np
from numpy.lib.stride_tricks import as_strided
def set_attr_force(obj, index, val):
while True:
xs = np.array([], dtype=np.uint64)
if (loc := xs.__array_interface__['data'][0]) < id(obj):
break
xs = as_strided(xs, strides=(1,), shape=((off := id(obj) - loc) + 1,))
ys = as_strided(xs[off:], strides=(8,), shape=(4,))
zs = as_strided(ys[3:], strides=(8,), shape=(index + 1,))
ys[2] += max(0, index - (end := len(obj)) + 1)
zs[min(index, end):] = id(val)
tup = (1, 2, 3)
print(tup)
set_attr_force(tup, 1, 'hm')
print(tup)
@dry mirage :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | (1, 2, 3)
002 | (1, 'hm', 3)
wonder if strings can be mutated 
!e
import numpy as np
from numpy.lib.stride_tricks import as_strided
def set_attr_force(obj, index, val):
while True:
xs = np.array([], dtype=np.uint64)
if (loc := xs.__array_interface__['data'][0]) < id(obj):
break
xs = as_strided(xs, strides=(1,), shape=((off := id(obj) - loc) + 1,))
ys = as_strided(xs[off:], strides=(8,), shape=(4,))
zs = as_strided(ys[3:], strides=(8,), shape=(index + 1,))
ys[2] += max(0, index - (end := len(obj)) + 1)
zs[min(index, end):] = id(val)
s = "abc"
print(s)
set_attr_force(s, 1, 'w')
print(s)
@dry mirage :x: Your 3.11 eval job has completed with return code 139 (SIGSEGV).
abc
does as_strided let you do memory corruption like that on purpose?
essentially yeah
since it needs to provide writable views into memory
This function has to be used with extreme care, see notes.
ah, handy
Hi guys
and gals
Anyone got a moment to look at something for me
This is the language compiling as constant data where it compiles the definition of each word within the command
print(A,WORD,IS,MADE,FOR,MORE,THAN,ONE,LETTER)
print(A,BOOK,CONSISTS,FOR,MORE,THAN,ONE,WORD)
print(A,SCRIPT,CONSISTS,FOR,MORE,THAN,ONE,WORD)
print(A,LIBRARY,CAN,HOLD,MANY,FORMS,FOR,SPECIFIC,KNOWLEDGE)
ACKNOWLEDGE SOMETHING WRITTEN AND OR SPOKEN ORDER OR COMMAND STATED AS DEVELOPED A NEW DEVELOPMENT STATING A STRUCTURE TO AN ENTITY LARGER AMOUNT BETWEEN CHOSEN VALUES 1 VARIABLE CONSTRAINED WITH FIELDS OF DATA INFORMATION THAT ACTS OUT AS A COMMANDED TASK
ACKNOWLEDGE SOMETHING A SPECIFIED STORAGE CONTAINER IN PAGES OF SCRIPTS FOR ONE DESIGNATED PLACE OF KNOWLEDGE CONTAINS STATING A STRUCTURE TO AN ENTITY LARGER AMOUNT BETWEEN CHOSEN VALUES 1 WRITTEN AND OR SPOKEN ORDER OR COMMAND
ACKNOWLEDGE SOMETHING A SINGLE STORAGE PAGE OF CODE CONTAINS STATING A STRUCTURE TO AN ENTITY LARGER AMOUNT BETWEEN CHOSEN VALUES 1 WRITTEN AND OR SPOKEN ORDER OR COMMAND
ACKNOWLEDGE SOMETHING STORAGE FOR LANGUAGES AND OR BOOKS ALLOW POSSIBILITY OUTCOME TAKE INTO COMMUNICATION OF SYNCHRONIZE LINK BETWEEN TWO VALUES WITH MAIN VALUE TO KEEP WITHIN BIND WITH DIFFICULT TO RESIST FROM BINDED VALUE MULTI MULTIS OF MORE THAN ONE MULTIPLES THAT MULTIPLICATE INTO GIVEN AMOUNT MORE THAN ONE FORM STATING A STRUCTURE TO AN ENTITY DETAILED FIELD CONTAINED WISDOM AND INTELLIGENCE AS ONE MEMORY STORAGE BANK
This is the data after a duplicate of the fully defined data is made in tuple form underneath the constant
('TAKE', (('THE STORAGE AREA', 'ENTER INPUT', 'CHOICE OF TWO OR MORE OUTCOMES WITHIN POSSIBILITY TO CREATE NEW VALUE INSIDE AND OUTSIDE EXISTENCE', ('AN ACT TO CALCULATE AND GIVE A SPECIFIC LENGTH ON SOMETHING', 'ENTER INPUT', 'CHOICE OF TWO OR MORE OUTCOMES WITHIN POSSIBILITY TO CREATE NEW VALUE INSIDE AND OUTSIDE EXISTENCE', ('CURRENT TIME', 'PUT IN A POSITION', 'ENTER INPUT', 'MEASUREMENT IN WHICH CURRENT REALITIES MUST PASS'), 'MORE THAN ONE REALITY', 'REQUIRED', 'ENTER AND TRANSFER'), 'REQUIRED', 'ENTER AND TRANSFER', 'GO INSIDE AND EXIT THE OPPOSITE DIMENSION FROM ENTRANCE'), 'STATEMENT TO DESCRIBE A FUTURE STATEMENT', 'STATED AS OBTAIN INSIDE CURRENT EXISTENCE', ('CURRENTLY LIVING DATA PARTICLES AS ONE OBJECT THAT EXISTS IN EXISTENCE', 'THE ACTION OF USING MULTIPLE MULTIVERSECODE WITHIN EVERY UNITED VALUE OF EXISTENCE WHILE UNIVERSAL OUTCOME', 'MORE THAN ONE MACRO', 'BETWEEN', 'DATA2 TO BE HELD INSIDE A DEVICE TO STORE A SKILL OR SKILLS', 'ADDED WITH', 'LIVE INSIDE EXISTENCE', 'ENTER INPUT', 'STATEMENT', 'PLACE OF ORIGIN', 'BETWEEN', ('AN ACT TO CALCULATE AND GIVE A SPECIFIC LENGTH ON SOMETHING', 'ENTER INPUT', 'CHOICE OF TWO OR MORE OUTCOMES WITHIN POSSIBILITY TO CREATE NEW VALUE INSIDE AND OUTSIDE EXISTENCE', ('CURRENT TIME', 'PUT IN A POSITION', 'ENTER INPUT', 'MEASUREMENT IN WHICH CURRENT REALITIES MUST PASS'), 'MORE THAN ONE REALITY', 'REQUIRED', 'ENTER AND TRANSFER'), 'CONNECT WORDS WHILE ALSO ADD', ('THE STORAGE AREA', 'ENTER INPUT', 'CHOICE OF TWO OR MORE OUTCOMES WITHIN POSSIBILITY TO CREATE NEW VALUE INSIDE AND OUTSIDE EXISTENCE', ('AN ACT TO CALCULATE AND GIVE A SPECIFIC LENGTH ON SOMETHING', 'ENTER INPUT', 'CHOICE OF TWO OR MORE OUTCOMES WITHIN POSSIBILITY TO CREATE NEW VALUE INSIDE AND OUTSIDE EXISTENCE',...
That is the language
That language is complete in all forms. Every definition defined and every word within the definition defined
I'm trying to get a good perspective of how it's actually handling the output
The way I made the language is every symbole and every letter can be part of a formula or equation to be made. Depending on the path chosen to make the command determines the route the system as I will call it will take. for each word you change in 1 single command the path can be entirely different. The words represent a piece of code which is in turn data which can be used to make an equation.
Numbers Symboles and Letters are the more advanced part of it that makes it so unique. Right now I am trying to see how the path formed from a set of constant data to an exact duplicate of the constant data in tuple form instead
I'm wondering if its grouping words based on reference or is it grouping them by connection
those are obviously two different outputs
!e
_ = lambda c,m :[print(bin(ord(j))[2:].zfill(max([len(bin(ord(k))[1:]) for k in c])).translate({49:11036,48:11035}))for j in (c+ c[-2::-1] if m==1 else c)]
_('<"">',1)
@maiden river :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ⬛⬜⬜⬜⬜⬛⬛
002 | ⬛⬜⬛⬛⬛⬜⬛
003 | ⬛⬜⬛⬛⬛⬜⬛
004 | ⬛⬜⬜⬜⬜⬜⬛
005 | ⬛⬜⬛⬛⬛⬜⬛
006 | ⬛⬜⬛⬛⬛⬜⬛
007 | ⬛⬜⬜⬜⬜⬛⬛
!e ```py
globals()[z] = type(z := (lambda _: str().join((s := map)(chr, s(round, (lambda a,b,c,d,e,f:(f/d(dcce-e)/(ddce-c-d),97*(d-e+d)ce/c/c+(A:=d*(f+e)-e)cce,(fb-accc)/(f+e)-e,(B:=(f-d+e)cdcde+(d+A)*cce), B+d+d+d+e))(12.3456, 99.8877, 2, 3, -1, 11)))))(), (type(z, (type,), {'repr': lambda a: a.name, 'lt': (_1 := lambda a, b: isinstance(b, int) and b >= 4), 'gt': (_2 := lambda a, b: isinstance(b, int) and b <= 3), 'le': _1, 'ge': _2, 'slots': (), 'dir': lambda _: ['bleem']})('foo', (type,), {}),), {'new': lambda a: bleem})
print(3 < bleem < 4)```
@magic wraith :white_check_mark: Your 3.11 eval job has completed with return code 0.
True
thats impressive
nice, so you can just put some random characters and it will give you a pattern?
let me try
!e
_ = lambda c,m :[print(bin(ord(j))[2:].zfill(max([len(bin(ord(k))[1:]) for k in c])).translate({49:11036,48:11035}))for j in (c+ c[-2::-1] if m==1 else c)]
_('<~àþþ~ff', 2)
@sudden osprey :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ⬛⬛⬛⬜⬜⬜⬜⬛⬛
002 | ⬛⬛⬜⬜⬜⬜⬜⬜⬛
003 | ⬛⬜⬜⬜⬛⬛⬛⬛⬛
004 | ⬛⬜⬜⬜⬜⬜⬜⬜⬛
005 | ⬛⬜⬜⬜⬜⬜⬜⬜⬛
006 | ⬛⬛⬜⬜⬜⬜⬜⬜⬛
007 | ⬛⬛⬜⬜⬛⬛⬜⬜⬛
008 | ⬛⬛⬜⬜⬛⬛⬜⬜⬛
WAIT A MINUTE
kinda sus ngl
!e ```py
_ = lambda c,m :[print(bin(ord(j))[2:].zfill(max([len(bin(ord(k))[1:]) for k in c])).translate({49:11036,48:11035}))for j in (c+ c[-2::-1] if m==1 else c)]
_('"'',1)
that code, how does it work?
!e```
_ = lambda c,m :[print(bin(ord(j))[2:].zfill(max([len(bin(ord(k))[1:]) for k in c])).translate({49:11036,48:11035}))for j in (c+ c[-2::-1] if m==1 else c)]
_('"'',1)
@ornate finch :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ⬛⬜⬛⬛⬛⬜⬛
002 | ⬛⬜⬛⬛⬜⬜⬜
003 | ⬛⬜⬛⬛⬛⬜⬛
!e ```
_ = lambda c,m :[print(bin(ord(j))[2:].zfill(max([len(bin(ord(k))[1:]) for k in c])).translate({49:11036,48:11035}))for j in (c+ c[-2::-1] if m==1 else c)]
_('"'',2)
@ornate finch :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ⬛⬜⬛⬛⬛⬜⬛
002 | ⬛⬜⬛⬛⬜⬜⬜
I fixed it up a bit```py
def function(c):
translates = {49:11036,48:11035}
for i in c:
fill = []
for j in c:
fill.append(len(bin(ord(j))[1:]))
fill = max(fill)
i = bin(ord(i))[2:]
i = i.zfill(fill)
i = i.translate(translates)
print(i)
_('<~àþþ~ff', 2)
function('<~àþþ~ff')```
!e ```
def function(c):
translates = {49:11036,48:11035}
for i in c:
fill = []
for j in c:
fill.append(len(bin(ord(j))[1:]))
fill = max(fill)
i = bin(ord(i))[2:]
i = i.zfill(fill)
i = i.translate(translates)
print(i)
_('<~àþþ~ff', 2)
function('<~àþþ~ff')
@ornate finch :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ⬛⬛⬛⬜⬜⬜⬜⬛⬛
002 | ⬛⬛⬜⬜⬜⬜⬜⬜⬛
003 | ⬛⬜⬜⬜⬛⬛⬛⬛⬛
004 | ⬛⬜⬜⬜⬜⬜⬜⬜⬛
005 | ⬛⬜⬜⬜⬜⬜⬜⬜⬛
006 | ⬛⬛⬜⬜⬜⬜⬜⬜⬛
007 | ⬛⬛⬜⬜⬛⬛⬜⬜⬛
008 | ⬛⬛⬜⬜⬛⬛⬜⬜⬛
oh so it gets the ascii code of each character and translates it to erm a square?
Suppose so not done looking it over tho yet
in the original code you can also make it reflect by putting a 1 instead of a 2
probably understood it alot better than I did lol
you can compute them from the desired image by simply writing the program in reverse
thats what i was thinking
tbh
!e
code
!e
def function(c):
translates = {49:11036,48:11035}
for i in c:
fill = []
for j in c:
fill.append(len(bin(ord(j))[1:]))
fill = max(fill)
i = bin(ord(i))[2:]
i = i.zfill(fill)
i = i.translate(translates)
print(i)
# _('<~àþþ~ff', 2)
function('<~àþþ~ff')
@sick hound :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ⬛⬛⬛⬜⬜⬜⬜⬛⬛
002 | ⬛⬛⬜⬜⬜⬜⬜⬜⬛
003 | ⬛⬜⬜⬜⬛⬛⬛⬛⬛
004 | ⬛⬜⬜⬜⬜⬜⬜⬜⬛
005 | ⬛⬜⬜⬜⬜⬜⬜⬜⬛
006 | ⬛⬛⬜⬜⬜⬜⬜⬜⬛
007 | ⬛⬛⬜⬜⬛⬛⬜⬜⬛
008 | ⬛⬛⬜⬜⬛⬛⬜⬜⬛
😅
@solar tulip :x: Your 3.11 eval job has completed with return code 1.
001 | File "<string>", line 1
002 | a = 1: if a == 1: print(a)
003 | ^
004 | SyntaxError: invalid syntax
How to make this work on one line?
!e ```py
a=1;a==1==print(a)
@floral meteor :white_check_mark: Your 3.11 eval job has completed with return code 0.
1
or even better (a:=1)==1==print(a)
Wait where is "if" gone?
a==1==print(a) is the same as writing a == 1 and print(a)
Essentially
And Python doesn't evaluate the rightmost side (print(a)) until a == 1 is True, so this condition acts as the if for the printing
I made a func to convert my 0 and 1s ascii art into a sequence of unicode chars : )
!e
j =[
"000111000",
"001000100",
"011000110",
"011111110",
"110000011",
"110000011"
]
#pattern to chars
def ptc(gr):
s=''
for b in gr:
s+=chr(int(b,2))
return s
#chars to pattern
def ctp (b,sz,m=0):
#sz=width,m=mirror on x axis, 1=true
if m==1:b+=b[-2::-1]
for z in b:
print(bin(ord(z))[2:].zfill(sz).translate({49:11036,48:11035}))
chars = ptc(j) #8DÆþƃƃ
ctp(chars,9)
print(ptc(j))
@maiden river :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ⬛⬛⬛⬜⬜⬜⬛⬛⬛
002 | ⬛⬛⬜⬛⬛⬛⬜⬛⬛
003 | ⬛⬜⬜⬛⬛⬛⬜⬜⬛
004 | ⬛⬜⬜⬜⬜⬜⬜⬜⬛
005 | ⬜⬜⬛⬛⬛⬛⬛⬜⬜
006 | ⬜⬜⬛⬛⬛⬛⬛⬜⬜
007 | 8DÆþƃƃ
!e Hence,
pattern= lambda c,m=0,l=-1 :[print(bin(ord(j))[2:].zfill(max([len(bin(ord(k))[2:]) for k in c])if l==-1 else l).translate({49:11036,48:11035}))for j in (c+ c[-2::-1] if m==1 else c)]
pattern("啕⪪䗑⯪坵⺺嵝㨮",1)
Where
c = chars, m: bool = mirror or nah,
l = length (default auto calculate)
@maiden river :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | ⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜
002 | ⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛⬜⬛
003 | ⬜⬛⬛⬛⬜⬛⬜⬜⬜⬛⬜⬛⬛⬛⬜
004 | ⬛⬜⬛⬜⬛⬜⬜⬜⬜⬜⬛⬜⬛⬜⬛
005 | ⬜⬛⬜⬛⬜⬜⬜⬛⬜⬜⬜⬛⬜⬛⬜
006 | ⬛⬜⬛⬜⬜⬜⬛⬜⬛⬜⬜⬜⬛⬜⬛
007 | ⬜⬛⬜⬜⬜⬛⬜⬛⬜⬛⬜⬜⬜⬛⬜
008 | ⬛⬜⬜⬜⬛⬜⬛⬛⬛⬜⬛⬜⬜⬜⬛
009 | ⬜⬛⬜⬜⬜⬛⬜⬛⬜⬛⬜⬜⬜⬛⬜
010 | ⬛⬜⬛⬜⬜⬜⬛⬜⬛⬜⬜⬜⬛⬜⬛
011 | ⬜⬛⬜⬛⬜⬜⬜⬛⬜⬜⬜⬛⬜⬛⬜
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/oyipurokiq.txt?noredirect
!e a scoop of ice cream
print(_:=+type((q:='_'),(),{q*(bool()**bool()+bool()**bool()):bool()**bool(),(q*7).replace(q*5,q*2+'a scoop of ice cream'[6:bool():-2]):lambda _:-_.__})())
@dense nova :white_check_mark: Your 3.11 eval job has completed with return code 0.
-1
!e
#ascoopoficecream
print(-1)
@arctic skiff :white_check_mark: Your 3.11 eval job has completed with return code 0.
-1
i die
!e
def SieveOfEratosthenes(n):
r,m=range,n+1
x,p=[1]*m,2
while p*p<=n:
if x[p]==1:
for i in r(p*p,m,p):x[i]=0;p+=1
[x[p]==1==print(p)for p in r(2,m)]
SieveOfEratosthenes(20)
@finite blaze :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | 2
002 | 3
003 | 5
004 | 7
005 | 9
006 | 11
007 | 13
008 | 15
009 | 17
010 | 19
I was trying to oneline this while loop
[[do_something for i in range(j)] for _ in iter(lambda: while_condition, True) if if_condition]
Into something like this but i can't get it to work
Wrong channel (see #❓|how-to-get-help), but it's because you're appending the list instead of the input
sorry
It it possible to catch segfault (and other signals) in python?
I want something like this:
with ignore_segfault():
ctypes.do_bad_stuff_in_C_code()
Is it possible on windows?
I am allowed to write some functions in C and then export them to some module
you can use multiprocessing to catch a function but only a function
https://learn.microsoft.com/cs-cz/windows/win32/debug/structured-exception-handling?redirectedfrom=MSDN you can afaik use this API
!e technically you can use signal handlers. as an alternative there is a way using the write syscall that you can detect if an address is useable in some way.
def valid(start):
from ctypes import c_char
import os
memory = (c_char*1).from_address(start)
r, w = os.pipe()
try:
if os.write(w, memory) == 1:
return True
except OSError:pass
finally:
os.close(r)
os.close(w)
return False
print(valid(0))
print(valid(0xfffffffff))
print(valid(id(1)))
@rugged sparrow :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | False
002 | False
003 | True
Can I get these lines in one line?
...
x1 = []
for x in range(y): n+=b; b*=f
return x2```
Something like this:
x1 = []; for x in range(y): n+=b; b*=f; return x2```
Is this even possible?
class gqKURcZbE_MnpEYOVYRTAWlSOna_suqs(object):
def Z_Ydgje_iGdodMdFDS_FScMuAQPgaI_j(wJTLzPVvwWhYTNcAA_dAmbfgtcmTFM_N):
wJTLzPVvwWhYTNcAA_dAmbfgtcmTFM_N.name = ''.join([chr(115), chr(115), chr(97), chr(108), chr(67), chr(109), chr(111), chr(100), chr(110), chr(97), chr(82)][::-1])
wJTLzPVvwWhYTNcAA_dAmbfgtcmTFM_N.description = ''.join([chr(102), chr(102), chr(117), chr(116), chr(115), chr(32), chr(101), chr(109), chr(111), chr(115), chr(32), chr(115), chr(101), chr(111), chr(100), chr(32), chr(115), chr(115), chr(97), chr(108), chr(99), chr(32), chr(115), chr(105), chr(104), chr(84)][::-1])
wJTLzPVvwWhYTNcAA_dAmbfgtcmTFM_N.version = ''.join([chr(48), chr(46), chr(49)][::-1])
wJTLzPVvwWhYTNcAA_dAmbfgtcmTFM_N.author = ''.join([chr(121), chr(117), chr(71), chr(32), chr(101), chr(109), chr(111), chr(83)][::-1])
def qwxyaDbvJfXJQBYMOsQmkOmwySiFLnsi(wJTLzPVvwWhYTNcAA_dAmbfgtcmTFM_N):
print(''.join([chr(8212), chr(353), chr(376), chr(240), chr(8212), chr(353), chr(376), chr(240), chr(8212), chr(353), chr(376), chr(240), chr(8212), chr(353), chr(376), chr(240), chr(8212), chr(353), chr(376), chr(240), chr(32), chr(107), chr(114), chr(111), chr(119), chr(32), chr(111), chr(116), chr(32), chr(103), chr(110), chr(105), chr(111), chr(71)][::-1]))
def PozSOIoeRoSZQmLdjzecmeIMldJacjfb(wJTLzPVvwWhYTNcAA_dAmbfgtcmTFM_N):
print(''.join([chr(8226), chr(732), chr(226), chr(8226), chr(732), chr(226), chr(8226), chr(732), chr(226), chr(8226), chr(732), chr(226), chr(8226), chr(732), chr(226), chr(32), chr(101), chr(101), chr(102), chr(102), chr(111), chr(99), chr(32), chr(103), chr(110), chr(105), chr(107), chr(97), chr(77)][::-1]))
def XexzOkriEgJODGdvyCdOlgm_XMKGdQIU(wJTLzPVvwWhYTNcAA_dAmbfgtcmTFM_N):
print(''.join([chr(180), chr(732), chr(376), chr(240), chr(180), chr(732), chr(376), chr(240), chr(180), chr(732), chr(376), chr(240), chr(180), chr(732), chr(376), chr(240), chr(180), chr(732), chr(376), chr(240), chr(32), chr(103), chr(110), chr(105), chr(112), chr(101), chr(101), chr(108), chr(83)][::-1]))
x1 = []; [(n:=n+b, b:=b*f) for _ in range(y)]; return x2
That should work. I changed the x in for x in range(y) to an underscore, since in general _ is recommended when you're not actually using whatever range(y) gives you.
ALL THE CHR FUNCTIONS!!!!!!!
oh hi
I will try.
What does it do?
Hello?
/-------------\
| Obfuscation |
\-------------/
hi
Ah, I see
obfuscated using this beauty
yes I have a legacy one
it makes ur code hella big
and take long to execute
Interesting
Hm
python going AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA FUUUUUUUUUUUUUUUUK
And run out of memory
Seems like a bad idea, but ok
anyways my newer obfuscator
it makes strings look frkn insane
also I need to add a length limit else it will crash
ast can't handle this string (yes I obfuscated the obfuscator using the obfuscator)
it will crash
Intriguing
Why not use argparse or something?
weight distribution
whats argparse
i hate emojis
Python's built-in library for command-line apps
You could put it to good use
I kinda like this more
It automatically adds help messages and stuff
like I don't need the BLOAT
And way more functionality
Like what more?
I already bundle to a very big exe
don't wanna add to that
def compile_bracketonly(source: str) -> str:
left,right="{","}"
ucp_store=[]
for char in source:
ucp_store.append(ord(char))
def _():
str_store=[]
for ucp in ucp_store:
store=[]
#print (ucp)
for _ in range(ucp):
store.append("(()==())")
resulting_string=f"{left}u({'+'.join(store)}){right}"
str_store.append(resulting_string)
return "".join(str_store)
return (f"""
u=chr
exec(f\"{_()}\")
""".strip())
if __name__ == "__main__":
import sys
import os
if os.path.exists(sys.argv[1]):
with open(sys.argv[1],"r") as f:
if len(sys.argv) > 2:
with open(sys.argv[2],"w") as f2:
f2.write(compile_bracketonly(f.read()))
else:
print("No output file specified")
#print(compile_bracketonly(f.read()))
else:
print ("File does not exist")
```try this beaut
it does
shit
it makes ur code
shit
and I love it
@royal whale
def calc(p: list, b: int):
f = p[0]; [(f += b, n += p[x+1]) for x in range(len(p)-1)]; return n```
No, thank you
does not work...
Hmm...
Maybe ill randomly make it sprinkle in detection
I can look into it
basically it will read itself, then go hey, do I have exec on the 2nd line, and do I not contain ;s on the first line
else it outputs heavily corrupted code
Okay, so += can't be used in a list comprehension.
Did you try out the version I sent you above?
!e
code
Any other way to make it in one line?
!e ```py
def calc(p: list, b: int):
f = p[0]; [(f += b, n += p[x+1]) for x in range(len(p)-1)]; return n
@full talon :x: Your 3.11 eval job has completed with return code 1.
001 | File "<string>", line 2
002 | f = p[0]; [(f += b, n += p[x+1]) for x in range(len(p)-1)]; return n
003 | ^^
004 | SyntaxError: invalid syntax
Yeah, probably
I saw only this method.
def calc(p: list, b: int):
n = p[0]; [(n += b, n -= p[x+1]) for x in range(len(p)-1)]; return n```
!e ```py
def calc(p: list, b: int):
n = p[0]; [(n += b, n -= p[x+1]) for x in range(len(p)-1)]; return n
@full talon :x: Your 3.11 eval job has completed with return code 1.
001 | File "<string>", line 2
002 | n = p[0]; [(n += b, n -= p[x+1]) for x in range(len(p)-1)]; return n
003 | ^^
004 | SyntaxError: invalid syntax
Doesn't quite work yet...
calc=lambda p,b:(f:=p[0],[(f:=f+b,n:=n+p[x+1])for x in range(len(p)-1)],n)[-1]
couldn't u use lambdas?
!e ```py
calc=lambda p,b:(f:=p[0],[(f:=f+b,n:=n+p[x+1])for x in range(len(p)-1)], n)[-1]
print(calc([10], 20))
@full talon :x: Your 3.11 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | File "<string>", line 1, in <lambda>
004 | UnboundLocalError: cannot access local variable 'n' where it is not associated with a value
print x
question: can you put function content and definition on one line
and then another function def after it
No.
😭
Not if you mean
def x(): something; def y(): something
a += b is statement, not expression
also question: does python optimize math expressions ran frequently?
I doubt it
Not sure though
no, why?
dang it
use pypy or numba if you are doing a lot of math
also does it precompile
# p is a list [0,1,2]
# b is an int 5
calc = lambda p, b:
n = p[0]
for x in range(len(p)-1):
n += b
n -= p[x+1]
calc = n```
Can someone do all this in one line?
Lol...
!e ```py
i assume you want return n at the end
calc = lambda p, b: (n := p[0], [(n := n + b, n := n - p[x + 1]) for x in range(len(p) - 1)], n)[-1]
@fleet bridge :warning: Your 3.11 eval job has completed with return code 0.
[No output]
al least it has no syntax errors
Why [-1] at the end?
Cuz you pull the last value out of the list?
It works.
I just don't get this:
, n)[-1]
I think I get it now. Thanks-
simplified:
calc = lambda p, b: (n := start_value, [here change n], n)[-1]
(..., ..., ...) is a tuple, so [-1] is the last element, which is n
it is very common practice when you need write some code in one line and you need to drop some values
here we must execute n := start_value, [here change n], but we dont care about result, we only need n
Thanks. 🙂
Can you also do this in one line?
def getlen(n: int, b: int, x=0):
while n > (b**(x)//(b): x += 1
return x```
I will try also.
it is harder, ill try
!e
getlen = lambda n, b, x=0: ({(x := x + 1, 0)[-1] for _ in iter((lambda: n > b**x//b), False)}, x)[-1]
@fleet bridge :warning: Your 3.11 eval job has completed with return code 0.
[No output]
What does iter do?
dark magic
Lmao.
!d iter
iter(object[, sentinel])```
Return an [iterator](https://docs.python.org/3/glossary.html#term-iterator) object. The first argument is interpreted very differently depending on the presence of the second argument. Without a second argument, *object* must be a collection object which supports the [iterable](https://docs.python.org/3/glossary.html#term-iterable) protocol (the `__iter__()` method), or it must support the sequence protocol (the `__getitem__()` method with integer arguments starting at `0`). If it does not support either of those protocols, [`TypeError`](https://docs.python.org/3/library/exceptions.html#TypeError "TypeError") is raised. If the second argument, *sentinel*, is given, then *object* must be a callable object. The iterator created in this case will call *object* with no arguments for each call to its [`__next__()`](https://docs.python.org/3/library/stdtypes.html#iterator.__next__ "iterator.__next__") method; if the value returned is equal to *sentinel*, [`StopIteration`](https://docs.python.org/3/library/exceptions.html#StopIteration "StopIteration") will be raised, otherwise the value will be returned.
you can change this code to not use cycle
Can you explain what the steps are?
and this
({(x := x + 1, 0)[-1] for _ in iter((lambda: n > b**x//b), False)}, x)[-1]
(x := x + 1, 0)[-1] - it is incrementing x and dropping its value, returning 0
{<x+=1> for _ in <some_iter>} - it is our while loop
({...}, x)[-1] - drop all, return x
iter((lambda: n > b**x//b), False) - it will give you items while n > b**x//b is true
.
NO IT IS WRONG?
fixed
getlen = lambda n, b, x=0: ({(x := x + 1, 0)[-1] for _ in iter((lambda: n > b**x//b), False)}, x)[-1]```
So this is correct?
i think so
I will check.
both getlen and calc can be implemented without using loops (even those weird loops)
ln = natural log
getlen = lambda n, b, x=0: return max(x, ln(n * b) / ln(b)) # most likely there are off-by-one errors
calc = lambda p, b: b * (len(p) - 1) + 2 * p[0] - sum(p) # most likely there are wrong coefficients
Oh, well the thing is these were only simple examples so I can implement it in my larger code.
So not litteral issues.
Just learning concepts here.
poopfart
Any good way to exec code in other Py version without manually installing interrupters
AKA if i wanted to marshal something in 3.7 and im running 3.10.
https://godbolt.org/ has 6 latest versions
But what if i wanted to automate this
you either manually install the interpreters, or you automate it with pyenv
wow, thankyou : )
They should pin this
then I should probably explain all this better and add examples
Anyone need a obfuscator
marshal.version```
Indicates the format that the module uses. Version 0 is the historical format, version 1 shares interned strings and version 2 uses a binary format for floating point numbers. Version 3 adds support for object instancing and recursion. The current version is 4.
is py 'abc'.replace('ab', 'de') equivalant to```py
str.replace('abc', 'ab', 'de')
as if so, I can make my code look insane
by replacing str with an alias
which is different every time
so ```py
str2.replace(str1.replace(str0.replace('\x40'# And so on
yeah
VAsyYauYodScalVlyxPRfFux_vxuiT_o = lambda n: type('')(n)
TigxgqGV_YGtdCIpTs_FKvQTtVNpUEbI = type(VAsyYauYodScalVlyxPRfFux_vxuiT_o(21))
r_lIhZjNxkbPgyzSEvwcwb_kDaGYClVj = TigxgqGV_YGtdCIpTs_FKvQTtVNpUEbI.split
print(r_lIhZjNxkbPgyzSEvwcwb_kDaGYClVj('hello world!', ' '))
run that
it does INSANE SHIT
may make all variable assignments a large function
which includes lambdas
like constant "321"? LJSVEjM_mxdOBpQSHYIDcSqbXVjDvKxS(0x141)
Should I add an -shuffle to my obfuscator
it shuffles names by indexing all the names
then replaces them with eachother
so u get stuff like ```py
class MakesCoffee(object):
def Make(self):
print("Making something")
class Makes(MakesCoffee):
def Make(self):
print("Making Cofee")
what obfuscator is that
I made the weight of underscores 300/362
DAMN
Hey @full talon!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
how good is this?
just run python obfuscator.py <infile> -o <outfile> -n -i -f -c
breaks when something else tries to call your class, for that ill add a flag soon
anyways that copy is broken
it lacks the -c flag
oh
only -C
@sick hound
try it
-n tells obfuscate variables
-i means obfuscate imports
-f means obfuscate functions
-c means obfuscate classes
M
I'm training myself to fix messy code by writing code so bad not even I can read it.
Wait which obfuscator is this
It seems more like a re-namer
mine
it does rename
more advanced obfuscation will come
it has a lot of bugs
I am fixing those
anyways redid how its being input
- now it generates
obfmaps
I just realized
inspired me to keep working on my obfuscator
like
a burst of motivation
okay
fixing a bug causing the obfmap to not include schmit from inside functions
classes are broken as shi
this is one hell of a thing just to get Z ```py
gdci('Z')
('builtins.getattribute(name.len().class.doc.getitem(157).add(name.len().class.doc.getitem(157)).add(name.len().class.doc.getitem(0)).add(name.len().class.doc.getitem(60)).add(name.len().class.doc.getitem(182)).add(name.len().class.doc.getitem(49)).add(name.len().class.doc.getitem(18)).add(name.len().class.doc.getitem(2)).add(name.len().class.doc.getitem(157)).add(name.len().class.doc.getitem(157)))(name.len().class.doc.getitem(18).add(name.len().class.doc.getitem(15))).doc', 2656)
!e ```py
print(builtins.getattribute(name.len().class.doc.getitem(157).add(name.len().class.doc.getitem(157)).add(name.len().class.doc.getitem(0)).add(name.len().class.doc.getitem(60)).add(name.len().class.doc.getitem(182)).add(name.len().class.doc.getitem(49)).add(name.len().class.doc.getitem(18)).add(name.len().class.doc.getitem(2)).add(name.len().class.doc.getitem(157)).add(name.len().class.doc.getitem(157)))(name.len().class.doc.getitem(18).add(name.len().class.doc.getitem(15))).doc[2656])
yes
!e ```py
print(builtins.getattribute(name.len().class.doc.getitem(157).add(name.len().class.doc.getitem(157)).add(name.len().class.doc.getitem(0)).add(name.len().class.doc.getitem(60)).add(name.len().class.doc.getitem(182)).add(name.len().class.doc.getitem(49)).add(name.len().class.doc.getitem(18)).add(name.len().class.doc.getitem(2)).add(name.len().class.doc.getitem(157)).add(name.len().class.doc.getitem(157)))(name.len().class.doc.getitem(18).add(name.len().class.doc.getitem(15))).doc[2656])
@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.
Z
@full talon :white_check_mark: Your 3.11 eval job has completed with return code 0.
Z
lemme JOINK that
fuk
@quartz wave so I am looking at working with an obfuscationmap
which I guess I won't do
as thats waaaaay too much work
@quartz wave
what do you even wanna do
simple: make all my code frkn unreadable
hold on i'm still working on my obfuscator while i have the motivation for it
Idea: make import <local file> eval('import file')
so intellisense and shit
won't work
and you don't know what it is
@quartz wave should I
yes
btw here's code to get exec in python 3.11 ```py
builtins.dict.getitem(name.len().class.doc.getitem(15).add(name.len().class.doc.getitem(5)).add(name.len().class.doc.getitem(15)).add(name.len().class.doc.getitem(206)))
3.10?
wait
how do u do that tho
I WANT IT GOD DAMN IT
So I can make all my internal functions shit
i made a function that extracts a string from five sources (all docstrings)
can u gimme
wait
the gdci and gs methods
wtf is that naming
@quartz wave I don't understand it
well turns out i don't need an obfuscator 🙂
oh my gosh
@quartz wave its broken


