#esoteric-python

1 messages · Page 53 of 1

subtle viper
#

untested ```py
def slashes(s):
m,=M="","";t=0;g=1
while s:
c,s=s;z="/"==gc;t+=z;g="\"!=g
c
if t>2:
while m[0]in(s:="".join(s))>"":s=s.replace(*m,1)
*m,=M;t=0
m[t-1]+=(t>z<g)*c;z<g>t==print(end=c)

#

okay tested :^

subtle viper
#

it's a lot shorter with a direct golf from the wiki though

#
def slashes(s):
 while s:
  m=["",""]
  for t in 0,1,2:
   while"/"!=s[:1]>"":m[t-1]+=s[z:="\\"==s[0]]*-~-(t<1!=print(end=s[z]));s=s[z+1:]
   s=s[1:]
  while m[0]in s>"":s=s.replace(*m,1)
fleet bridge
#

wow, kinda like self-modifying Markov algorithms
very cool language

#
list(s)
[*s]
#
while(cond):
while cond:
#
while(s:=...)and m in s:
while(s:=...)*(m in s):
#

oh, y'all already golfed the hell out of it :-)

subtle viper
#

true..

covert temple
#

my golf, not including a glob import from build123d:```py
(v:=(a:=Sphere(26)).volume,print((v-18*(v-(a-(l:=lambda m,p:extrude(Pos(Z=m)Circle(4.5),amount=8.5,taper=p))((16,0))-l((24.5,-45))).volume)).00102))

subtle viper
#

i see golfery but with a bit of spaghettiery

arctic skiff
covert temple
#

Nice, I suspected there was something silly I was doing with the print statement.

magic wraith
#

!e py import ast print(ast.unparse(ast.parse("f'{a:{{x}}}'")))

night quarryBOT
magic wraith
#

a random space appeared, literally unusable 🤐

versed eagle
#

Warning: The produced code string will not necessarily be equal to the original code that generated the ast.AST object

grave grail
#

I think the reason they post it is not because they are not the same but specifically the extra space is annoying to watch for them

subtle viper
#

people might go around thinking f"{a:{{x}}}" has a format string == r"{x}"

#

why isn't it like that anyways..

versed eagle
#

mhm

#

augh you're evil

#

forgie ||i LOST the game|| because of your bio

subtle viper
#

okay now i did too.

#

god i hate these correlations =へ=

versed eagle
#

my brain was like
||oh darn thats loss
i got tricked into thinking about it
whats another thing that people get tricked into thinking about?
aha! and then i lost||

#

because ||loss and losing the game contain the same root work||

#

meow

subtle viper
#

meow

versed eagle
#

sorry

grave grail
#
class __Mutex1: ...
class __Mutex2: ...

class IsTemplate(__Mutex2, __Mutex1): ...
class IsUI(__Mutex1, __Mutex2): ...

class Valid1(IsUI): ...
class Valid2(IsTemplate): ...
try:
    class Invalid1(IsUI, IsTemplate): ...
    raise AssertionError
except TypeError:
    ...
try:
    class Invalid2(IsTemplate, IsUI): ...
    raise AssertionError
except TypeError:
    ...

Does anyone have usecase of this

magic wraith
magic wraith
grave grail
#

Well, you would know by basic mro
The question is other than obfu

grave grail
#

Does anyone know dark magic that edit the subclass of a class

arctic skiff
#

assuming your child class exist in globals

grave grail
#

No, it might not be in globals, you are only given the class object and some need to somehow manipulate such

#

Currently looking at rn on editing the class of the object to have the same behaviour by init and init_subclass

arctic skiff
#

oh wait

#

there is .__subclasses__()

#

@grave grail

#

!epy print(int.__subclasses__())

night quarryBOT
grave grail
#

Oh oops I described it wrong
I meant
B(A)
How can I edit B so now it also inherit C, D (or whatever)

#

And unfortunately B.__mro__ is not an editable attribute

restive void
grave grail
#

Let me check

#

Hmm, but it unfortunately doesn't work when you have multiple class C(B, A)

grave grail
#

...Why?

#

Wtf

#

!e

class A:
    def __init_subclass__(*args, **kwargs):
        print(args, kwargs)

print(A.__init_subclass__)

class B(A):...

def __init_subclass__(*args, **kwargs):
    print(args, kwargs)

A.__init_subclass__ = __init_subclass__

class C(A):...

class Asub:
    def __init_subclass__(*args, **kwargs):
        print(args, kwargs)

A.__init_subclass__ = Asub.__init_subclass__


class E(A):...
night quarryBOT
restive void
# grave grail ...Why?

Because (Objects/typeobject.c \approx L3733)

    /* Special-case __init_subclass__ and __class_getitem__:
       if they are plain functions, make them classmethods */
#

Make that A.__init_subclass__ = classmethod(__init_subclass__) and it behaves the same.

grave grail
#

Oh ok, thx

grave grail
#

Done it but haven't test does it impact how you use the class

vernal fjord
#

i was told to post this here, one-line hangman

(_a_ := "train") and (_b_ := "_" * len(_a_)) and not (_c_ := 0) and ((f := lambda _: print(0) if globals()["_b_"] == globals()["_a_"] else f(str(globals().__setitem__("_b_", (g := input()) * 0 + "".join([v if g == v else globals()["_b_"][i] for i, v in enumerate(globals()["_a_"])]))) * 0 + str(globals().__setitem__("_c_", globals()["_c_"] + 1 * (not g in _a_))) * 0 + str(print(globals()["_b_"], _c_)) * 0) if globals()["_c_"] < 6 else print(1))(""))


"""
DESCRIPTION:
_a_ := solution word (here: "train")
_b_ := what's shown (like: "tr__n")
_c_ := error counter

(word:="train") and (display:="_"*len(word)) and not (errors:=0) and (                                 # define prerequisites
(f := lambda _:                                                                                        # main recursive function
    print("WINNER!!!") if globals()["display"] == globals()["word"] else f(                            # exit - once you've won, else:
        str(globals().__setitem__("display", (g:=input())*0+                                           #     generate and \
            "".join([v if g==v else globals()["display"][i] for i,v in enumerate(globals()["word"])])  #     update display
        ))*0 +  #                       easter egg                                                     #     nothing much
        str(globals().__setitem__("errors",globals()["errors"] + (not g in word)))*0+                  #     count errors
        str(print(globals()["display"],errors))*0                                                      #     print display (and errors)
    ) if globals()["errors"] < 6 else print("YOU LOST!!!!!")                                           # exit - once you've lost
)(""))
"""
grave grail
#

Nice

grave grail
grave grail
hybrid trail
subtle viper
# subtle viper compressable
"""
DESCRIPTION:
a := solution word (here: "train")
b := what's shown (like: tr__n)
c := attempts left

(
    word := "train",                                                      # \
    display := "_" * len(word),                                           #  |- define prerequisites
    left := 6,                                                            # /
    [
        print(display, left := left + (g in word)-1)                      # print display (and count and print attempts left) (executes last)
        for _ in iter(lambda: left * (display != word), 0)                # main loop, exit if either:
                                                                          #     - no attempts left (left == 0)
                                                                          #     - display is equal to word [(display != word) == False == 0]
                                                                          # else:
        if (                                                              #     nothing much
            g := input(),                                                 #     generate and \
            display := "".join(t[g == t[1] for t in zip(display, word)),  #     update display
        )  #                  easter egg                                  # then do the printing written above
    ],
    print("WINNER!!!" if c else "YOU LOST!!!!!")                          # show if you've won or lost
)                                                                         # fin
"""
(a:="train",b:="_"*len(a),c:=6,[print(b,c:=c+(g in a)-1)for _ in iter(lambda:c*(b!=a),0)if(g:=input(),b:="".join(t[g==t[1]]for t in zip(b,a)))],exit(c<1))
``` semi-golfed
hybrid trail
#

nice

#

now to find a good way of generating five letter words...

#

my first idea:

__import__('random').choice([*{*__import__('re').findall(r'\b[a-z]{5}\b', open(__import__('difflib').__file__).read())}])
#

difflib gives nearly 200 valid words but obviously not the shortest

subtle viper
hybrid trail
#

Also the code should be modified to print the word at the end

#

just ```py
[{import('re').findall(r'\b[a-z]{5}\b', open(import('difflib').file).read())}][0]

stable hornet
#

Hangman with the man: py [w:=[*'smile'],G:={7},(r:=lambda s:(g:=8-len(G-{*w}),print(*s),s==w>exit(),H:='\n| \\ / \n| \\│/ \n| O \n| ┃ \n+--+ ',[H:=H.replace(c,' ',1)for c in r'\/\│/O┃'[:g]],print(H[::-1]),g==0>exit(),G>{c:=input()}>r(s),G.add(c),s:=[[b,a][c==a]for a,b in zip(w,s)],r(s)))(['_']*5)] (improved version)py [w:='maeli',G:={7},(r:=lambda s:(g:=len(G-{*w}),print(*s),G>{*w}>exit(),H:=r''' +--+ | | O | /|\ | / \ |''',[H:=H[:c]+' '+H[c+1:]for c in b'? '[g:]],print(H),g>7>exit(),G>{c:=input()}>r(s),G.add(c),s:=[[b,a][c==a]for a,b in zip(w,s)],r(s)))('_'*5)]

stray grove
grave grail
#

you shouldn't be using esoteric code in production

vernal fjord
vast carbon
#

What is esoteric-python?

grave grail
#

Writing code that looks cursed but functions as required

earnest wing
jaunty lake
#

Everyone always asks what esoteric python is, no one ever asks how esoteric python is

arctic skiff
clear venture
#

It was a meme nerd

subtle viper
versed eagle
#

yeah

#

meow

fleet bridge
versed eagle
wary python
subtle viper
#

meow

arctic skiff
#

guess esoteric python is no more

past forge
#

This has become the server's pet channel

grave grail
#

Anyone want to golf this thing
Requirement, as_mutex API must be usable as it is now and it function in same way

vernal fjord
#

what do yall think of my oneliners?

_1liner1 = (word := "k") and (display := "_" * len(word)) and not (errors := 0) and ((f := lambda _: print("WINNER!!!") if globals()["display"] == globals()["word"] else f(str(globals().__setitem__("display", (g := input()) * 0 + "".join([v if g == v else globals()["display"][i] for i, v in enumerate(globals()["word"])]))) * 0 + str(globals().__setitem__("errors", globals()["errors"] + 1 * (not g in word))) * 0 + str(print(globals()["display"], errors)) * 0) if globals()["errors"] < 6 else print("YOU LOST!!!!!"))(""))


_1liner2=[w:="face",d:="_"*len(w),v:=globals().__setitem__,p:=print,hangman:=("          2222222222222222222222222222222222\n                1                         3\n                1                         3\n                1                         3\n                1                       44444\n                1                     44     44\n                1                    4  9   9  4\n                1                    4         4\n                1                     44 888 44\n                1                       44444\n                1                         5\n                1                         5\n                1                         5\n                1                         5\n                1                         5\n                1                        6 7\n            000000000                   6   7\n        00000000000000000              6     7\n      000000000000000000000           6       7")+"\n"*5,glyphs:="#|_|o|/\\~x",e:=0,enum:=enumerate,h:=lambda x:p("".join(glyphs[int(j)]if j.isdigit()and int(j)<x else j if not j.isdigit()else" "for i,j in enum(hangman))),(f:=lambda _:(p("WINNER!!!")if w==d else p("LOSER!!!")if e>=10 else(v("d","".join(i if i==g_ else d[j]for j,i in enum(w)))or p("correct guess")or p(d)or f(0))if(g_:=input(">"))in w else(v("e",e+1)or p("incorrect guess")or h(e)or f(0))))(0)]

guess what they do :)

subtle viper
#

hangman

vernal fjord
#

you ran it >:(

subtle viper
#

there's a huge hangman ASCII art in the middle, y'know.

vernal fjord
#

oh :/

subtle viper
#

also i did the deobfuscating + regolfing of your other code

#

and kind of figured it out along the way

vernal fjord
#

ohh

#

yeah i forgor- 💀

#

i made a second one

#

oneliner2 = [
    v:=globals().__setitem__,
    p:=print,
    hangman:= ("          2222222222222222222222222222222222\n                1                         3\n                1                         3\n                1                         3\n                1                       44444\n                1                     44     44\n                1                    4  9   9  4\n                1                    4         4\n                1                     44 888 44\n                1                       44444\n                1                         5\n                1                         5\n                1                         5\n                1                         5\n                1                         5\n                1                        6 7\n            000000000                   6   7\n        00000000000000000              6     7\n      000000000000000000000           6       7") + "\n" * 5,
    glyphs:="#|_|o|/\\~x",
    e:=0,
    w:="face",
    d:="_"*len(w),
    g:=input,
    enum:=enumerate,
    h:=lambda x:p("".join(glyphs[int(j)] if j.isdigit() and int(j)<x else j if not j.isdigit() else " " for i,j in enum(hangman))),
    #           print hangman
    (f:=lambda _: (v("d","".join(i if i==g_ else d[j] for j,i in enum(w))) or p("correct guess") or p(d) or f(0)) if (g_:=g(">")) in w else (v("e", e+1) or p("incorrect guess") or h(e) or f(0) if e<10 and not w==d else p("WINNER!!!") if w==d else p("LOSER!!!")))(0)
    #             update progress (display var)                                 and print guess         and progress    if guess is right    else  increase err count and print hangman                       -!- recursion exits -!-                 [win] | [loss]
]
#

description

subtle viper
#

i need eep now, bye

vernal fjord
#

gn

torn tulip
grave grail
#

You will get like:
Why does it not work?
The reason is it was not on the test case and therefore the code don't have to obey such

vernal fjord
#

!e print(type(3//3.0) is float)

night quarryBOT
vernal fjord
#

so float // int := float, yet

#

!e print(4//1.5)

night quarryBOT
vernal fjord
#

wow, just wow. rounds to an integer but returns it as a float

#

!e print("abcde"[4//1.5])

night quarryBOT
# vernal fjord !e print("abcde"[4//1.5])

:x: Your 3.13 eval job has completed with return code 1.

001 | /home/main.py:1: SyntaxWarning: str indices must be integers or slices, not float; perhaps you missed a comma?
002 |   print("abcde"[4//1.5])
003 | Traceback (most recent call last):
004 |   File "/home/main.py", line 1, in <module>
005 |     print("abcde"[4//1.5])
006 |           ~~~~~~~^^^^^^^^
007 | TypeError: string indices must be integers, not 'float'
vernal fjord
versed eagle
#

it floors the result

austere mauve
vernal fjord
#

oopsie-

austere mauve
proper vault
night quarryBOT
arctic skiff
versed eagle
brisk zenith
#

that's actually a really cool demonstration though

#

!e ```py
from decimal import Decimal
print(Decimal(1e200) / Decimal(2e198))

night quarryBOT
brisk zenith
#

classic

restive void
#

!e

from decimal import Decimal
print(Decimal("1e200") / Decimal("2e198"))
night quarryBOT
brisk zenith
#

!e ```py
from decimal import Decimal

print(1e200 / 2e198 == 50)
print(Decimal(1e200 // 2e198))

night quarryBOT
brisk zenith
#

interesting

#

wait that's not what i meant

versed eagle
#

ieee754 double precision floating point numbers cant

vernal fjord
#

but get this

#

!e

print(1e200/2e198, 1e200//2e198, 8e100/2.0e100==8e100//2.0e100)
magic wraith
#

!e py print(int(1e200)//2e198) print(1e200//int(2e198))

night quarryBOT
night quarryBOT
versed eagle
vernal fjord
#

she put the entire calculation into Decimal(...), that kinda defeats the purpose of the module

#

or he, whatever

versed eagle
#

was that not on purpose

vernal fjord
#

I don't think so

magic wraith
#

you're not supposed to call Decimal() and give it a float

#

1e200 is a float

vernal fjord
#

that's why you do Decimal("1e200")

#

or Decimal(int(10**200))/Decimal(int(2*10**198))

proper vault
#

for example, ```py

decimal.Decimal(0.3)
Decimal('0.299999999999999988897769753748434595763683319091796875')

errant crescent
brisk zenith
brisk zenith
#

(i just didn't get it right ;D)

grave grail
#

Nice

errant crescent
errant crescent
# errant crescent floor division returns a float, if either side of the operation is a float. fli...

https://docs.python.org/3/library/stdtypes.html

  1. Also referred to as integer division. For operands of type int, the result has type int. For operands of type float, the result has type float. In general, the result is a whole integer, though the result’s type is not necessarily int. The result is always rounded towards minus infinity ...
  1. ... for complex numbers ... convert to floats using abs() if appropriate.
grave grail
untold sparrow
#

!e

magic wraith
grave grail
#

Which come from help from previous message which come from help from other members

brisk zenith
#

+1 for rust

#

actually, i just saw lines 76-81 in your gist. that's funny

grave grail
hybrid trail
#

Let a radiation safe expression be one such that it and any deletion of a single character evaluates to the same integer in python. For example, 00 is a radiation safe expression that evaluates to 0. Is there a radiation safe expression for every number 1-100? What is the shortest program that prints a radiation safe expression for each n 1-100?

grave grail
#

The deletion of it:
How much it is deleting, a character or a token?

hybrid trail
#

character

quartz wave
#

just one?

hybrid trail
#

yep

grave grail
#

I mean, if it can be more than one(non restrictive), then there are no radiation safe expressions that can evaluate to integer lol

hybrid trail
#

edited for clarity

#

first challenge is finding one that evaluates to 1 :)

#

for example ||00**00|| is close

grave grail
#

Apparently you cannot use leading 0 except 0

grave grail
earnest wing
#

nice

grave grail
#

The reason why cannot just use 2 is apparently 0**0**0 is 0

earnest wing
#

yep 0**(0**0)

#

does 11<122<11123 count, being a boolean?

#

for any sufficiently tight binding result for 1 you can always ++ it to itself for larger numbers

#

(assuming it also works with 0 removals)

earnest wing
#

if you can do <expr for 1>++<expr for 1> without needing parentheses around the expressions you have an expression for 2

#

unary + is kinda goated actually

grave grail
#

Oh

compact trench
#

has anyone figured out how to edit a live generator's entry point, or code body? or even a non-live function's code body in-place?

#

sure it's virtually guaranteed to be a disaster, but is it possible?

stable hornet
night quarryBOT
compact trench
#

wow

#

hmmm

#

!e

def foo(a):
  print(f"foo {a=}")
  b = yield a
  print(f"foo {b=}")
  c = yield b
  print(f"foo {c=}")

def bar(a):
  print(f"bar {a=}")
  b = yield a
  print(f"bar {b=}")
  c = yield b
  print(f"bar {c=}")

x = foo(3)
a = next(x)
b = x.send(99)
x.gi_code = bar.__code__
c = x.send(40)
night quarryBOT
# compact trench !e ```py def foo(a): print(f"foo {a=}") b = yield a print(f"foo {b=}") c...

:x: Your 3.13 eval job has completed with return code 1.

001 | foo a=3
002 | foo b=99
003 | Traceback (most recent call last):
004 |   File "/home/main.py", line 18, in <module>
005 |     x.gi_code = bar.__code__
006 |     ^^^^^^^^^
007 | AttributeError: attribute 'gi_code' of 'generator' objects is not writable
compact trench
#

even using object.__setattr__(x, "gi_code", bar.__code__) doesn't work

stable hornet
#

what kind of behaviour are you trying to get here?

compact trench
#

to assert dominance over the interpreter

#

it's my computer and i decide what the bytes are

#

but yeah tbh i am disappointed to not be able to control every aspect of python objects that aren't like... Ctypes

#

i can understand a Ctype or something, but generator is a fundamental object

fleet lintel
#

I’m not familiar enough with C/Ctypes to figure it out, but it looks like the code uses &gen->gi_frame so if you got the offset of the struct field couldn’t you write to it to change the frame it’s pointing to?

compact trench
#

ooooooo interresting

karmic pumice
fleet lintel
# compact trench ooooooo interresting

!e This sort of works, based on a ton of assumptions and will probably break everything. It only works when the generated item is a constant item, and doesn't overwrite the length, so I guess those are stored somewhere else I didn't overwrite. This also gets a bit silly, since when you are turning to using ctypes like this you are basically using a memory editor and could do anything. ```py
def swap_generator(old, new):
# based on https://stackoverflow.com/a/45698304
import ctypes
# Assumes 64-bit operation system, size is 8, 10th element for 89 offset
(ctypes.c_longlong).from_address(id(old) + 8
9).value = id(new.gi_code)
# Manually increase refcount to pretend this is a good idea
(ctypes.c_longlong).from_address(id(new.gi_code)).value += 1

print("works :)")
gen = (1 for _ in [1, 2, 3])
print(next(gen))
swap_generator(gen, (2 for _ in [1, 2, 3, 4]))
print(*gen)

print("doesn't :(")
gen = (x for x in [1, 2, 3])
print(next(gen))
swap_generator(gen, (x for x in [9, 8, 7, 6]))
print(*gen)

night quarryBOT
compact trench
fleet lintel
#

Also, you could make a C extension to avoid all of this ctypes memory editing nonsense

compact trench
#

perhaps you could...

def falsey():
  self = yield
  
  while (x != y):
    ... same as plane

def plane():
  self = yield
  
  while (x == y):
    (ctypes.c_longlong).from_address(id(self) + 8*...).value = id(new.__code__)
    (ctypes.c_longlong).from_address(id(falsey.__code__)).value += 1
    ...

def engine() -> plane:
  x = plane()
  next(x)
  x.send(x)
  return x
#

so you could have the loop conditionally invert itself (and arbitrarily many other simple 1-1 operator changes) at runtime

#

all without having to resort to that ugly old python trick of just "suffix booleans with == a; and change a"

#

this is all incredible, really

#

i wonder if you could, through careful manipulation... use the python EXPR datastack as a stack

#

you would need to alter the value in the middle of an operation, perhaps with :=

fleet lintel
#

I’m confused what you’re trying to do or why

subtle viper
#

for the JIT-type interpreter, the offset of the executing code is probably entirely internal-only

fleet lintel
# compact trench so you could have the loop conditionally invert itself (and arbitrarily many oth...

I don't understand why you would need cursed things for this, why not define a custom iterator with that behavior? ```pycon

class FlipFlopGen:
... def init(self, state):
... self.state = state
... def iter(self):
... return self
... def next(self):
... return self.state
... def flip(self):
... self.state = not self.state
... x = FlipFlopGen(True)
... print(next(x))
... print(next(x))
... x.flip()
... print(next(x))
... print(next(x))
...
True
True
False
False

subtle viper
compact trench
#

and esp. with generators i mean this kind of alternation is trivial enough without even needing a custom object, just have a variable, but my example is just that

fleet lintel
night quarryBOT
# fleet lintel !e The c code, I just found it using ```py import ctypes gen = (1 for x in [1]) ...

:white_check_mark: Your 3.13 eval job has completed with return code 0.

001 | 139751458934096
002 | 0 c_long(1)
003 | 1 c_long(139751469414496)
004 | 2 c_long(0)
005 | 3 c_long(139751469465616)
006 | 4 c_long(139751469465616)
007 | 5 c_long(0)
008 | 6 c_long(0)
009 | 7 c_long(139751459108272)
010 | 8 c_long(139753891832256)
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/ANKMWZDKS6M5DTF2ADC56BMVQQ

fleet lintel
#

And you can see 9 has the same value as the id, so it's the correct offset

compact trench
#

smart

subtle viper
#

i see

fleet lintel
subtle viper
#

you're counting PyObject_HEAD as 1 pointer and the chars as 1 pointer

fleet lintel
#

IDK it seems to line up and work, I really have no clue what I'm doing

subtle viper
#

it's a coincidence :p

fleet lintel
#

That's funny

subtle viper
#

which is the code object of the frame of the generator

#

oh. i get it now

#

an internal interpreter frame is technically stored as an "array" inside the generator object

#

since C arrays are just glorified pointers

fleet lintel
#

Don't all c-based python objects use slots? Or do you mean something different?

subtle viper
#

so by changing that, the first field of the iframe (a.k.a. the code object of the generator frame) is modified

subtle viper
#

like the getters and setters referencing fields?

fleet lintel
#

__slots__

subtle viper
#

oh
i don't really know, but aren't internal object struct fields basically like that anyway

#

as in they're stored after the object [header]

fleet lintel
subtle viper
subtle viper
#

so in order to change the iterator, the running stack must be changed

karmic pumice
versed eagle
#

because ||x2 is aligned|| to ||an 8 byte boundary||

karmic pumice
subtle viper
#

i meant like they count the chars as 1 pointer each regardless of the adjacency

grave grail
#

An pointer should be 4 byte thopithink

karmic pumice
subtle viper
#

oh right

#

3 pointers**

subtle viper
#

not 3 bytes

subtle viper
#

struct packing is such a weird thing in C

grave grail
#

Tbf, why you say char is a pointer tho

subtle viper
#

i was referring to how they counted the fields as 1 pointer each, including the ones with the type of char

versed eagle
#

unless you put 9 chars there :3

quartz wave
quartz wave
fleet lintel
#

Wow

quartz wave
#

fun. fact. this: py r = [x for _ in _ for x in [1]] is the same as this: ```py
r = []
for _ in _:
for x in [1]:
r.append(x)

BUT THIS: ```py
r = [x for _ in _ for x in [nonconst]]
``` IS THE SAME AS THIS. ```py
r = []
for _ in _:
    x = nonconst
    r.append(x)
karmic pumice
quartz wave
#

i mean that doesn't really trouble me, it's just the fact that it's inconsistent \( T^T )/

karmic pumice
#

well its consistent by behavior isnt it
for x in [1] is basically x = 1

quartz wave
#

it somehow doesn't do it when it's a constant sequence?? why??

karmic pumice
#

because it can be stored as a constant tuple in the bytecode?

quartz wave
#

i'm just saying why not apply that assignment opt. first before the constant sequence iteration opt.

quartz wave
versed eagle
#

girl

#

what you're doing is really cool

#

im kind of too tired to phrase things well but uh yeah

#

you're awesome and stuff

quartz wave
#

tyy ^_^

twin roost
#

!e

def test_list():
    "V" in ['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']

def test_tuple():
    "V" in ('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')

def test_set():
    "V" in {'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'}

import dis
dis.dis(test_list)
dis.dis(test_tuple)
dis.dis(test_set)
night quarryBOT
# twin roost !e ```python def test_list(): "V" in ['A','B','C','D','E','F','G','H','I','J...

:white_check_mark: Your 3.13 eval job has completed with return code 0.

001 |   1           RESUME                   0
002 | 
003 |   2           LOAD_CONST               1 ('V')
004 |               LOAD_CONST               2 (('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'))
005 |               CONTAINS_OP              0
006 |               POP_TOP
007 |               RETURN_CONST             0 (None)
008 |   4           RESUME                   0
009 | 
010 |   5           LOAD_CONST               1 ('V')
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/SEAWRGMKLW5P4RDLKMAIIOUIBY

twin roost
#

TIL I learned that Python doesn't build sets and lists if they are just needed for CONTAINS_OP

quartz wave
#

(if constant elements)

twin roost
#

yes

#

it's cool that it's reusing a tuple / frozenset saved from co_consts

#

I thought Python always does just what it's told to do, without making this kind of optimizations

quartz wave
#

also "V" in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

#

though it's pretty unremarkable

twin roost
#

!e

import dis
def test_str():
    "V" in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
dis.dis(test_str)
night quarryBOT
quartz wave
#

none, that's why it's unremarkable

twin roost
#

)

#

!e

import dis

def test_list():
    a = ['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']
    "V" in a

dis.dis(test_list)
night quarryBOT
# twin roost !e ```python import dis def test_list(): a = ['A','B','C','D','E','F','G','...

:white_check_mark: Your 3.13 eval job has completed with return code 0.

001 |   3           RESUME                   0
002 | 
003 |   4           BUILD_LIST               0
004 |               LOAD_CONST               1 (('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'))
005 |               LIST_EXTEND              1
006 |               STORE_FAST               0 (a)
007 | 
008 |   5           LOAD_CONST               2 ('V')
009 |               LOAD_FAST                0 (a)
010 |               CONTAINS_OP              0
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/FY6SYNPIADWUUCMZIQX3QVRFJE

twin roost
#

I would be amazed if it would cover that 😄

#

though no idea if CONTAINS_OP const + local name is any less efficient than CONTAINS_OP const + const

twin roost
#

Kind of annoying that there is no non-esoteric way to access frozenset from co_consts without creating a new set. And something like frozenset({1, 2, 3}) would end up creating 3 set objects...

plush frigate
hybrid trail
# plush frigate https://github.com/ivuqarism/password-gen

243

import random
from string import*
b=lambda s:"ny".index(input(s+'? '))
print("".join(random.choices(ascii_letters[:26*-~b('Use capital letters')]+digits*b('Use numbers')+"!@#$%^&*()-_=+[]{}|;:,.<>?/"*b('Use symbols '),k=int(input("Length")))))
twin roost
#

Are there things that annoy you when you see them in python code, because you know some internal details (maybe even something on the opcode level), though they don't really matter and working around them might not bring any real benefits?

E.g. I have it every time I see if hasattr(a, x): y = a.x when __getattr__ is not just default method and it has some other stuff in it - it's annoying because I know that hasattr is basically getattr with AttributeError exception catch, so it's basically calling getattr twice for no reason.

quartz wave
#

maybe, but i kind of do the double getattr myself in non-esoteric code

hybrid trail
#

code golf: given two lines of input A and B, print A with all instances of the substring B replaced by a space.

proper vault
#

print(input().replace(input(),' '))

hybrid trail
#

good start 👀

#

par is ||30||

proper vault
#

does that count newlines as characters?

earnest wing
#

31 ||

exit(str.replace(*open(0),' '))

||

proper vault
#

short a )

earnest wing
#

oop

proper vault
#

31||I=input;I(I().replace(I(),' '))|| not sure this counts.

restive void
#

||print(*input().split(input()))|| 30?

earnest wing
#

that's so cute

hybrid trail
quartz wave
hybrid trail
#

also clever

#

truly unfortunate how newlines get in the way :(

quartz wave
#

newlines shouldn't usually cause a problem for this format

restive void
#

!tvmute 880102329335046246 2w This is not how you get voice-verified. Posting "hi" across many channels definitely counts as spamming.

night quarryBOT
#

:incoming_envelope: :ok_hand: applied voice mute to @torn cave until <t:1751452045:f> (14 days).

torn cave
#

uh

#

ok

#

fair enough

magic wraith
twilit igloo
#

is this the same language

#

as what i used like seconds ago to make my project

karmic pumice
#

i mean it does "print" but it also starts taking input

restive void
#

But input only takes one argument, it doesn't space-join the prompt like print does

karmic pumice
earnest snow
#

!rule 6

night quarryBOT
#

6. Do not post unapproved advertising.

cyan scaffold
#

What's everyone's favorite bit of esoteric python?

polar plover
cyan scaffold
#

Oh?

polar plover
#

!e ```py
class Foo(map(0,"")):pass
print(Foo)

night quarryBOT
quartz wave
grave grail
quartz wave
#

!e ```py
try:
for {}[()] in [()]*(()==()):
x = a, *v = a[0], *_ = [0], 7, 2
x[0] += sum(v),
except TypeError:
print(x)

night quarryBOT
cyan scaffold
#

Was a fun exercise

#

You can even replace the standard object base type if you want

#

I was trying to build a truly immutable object/type. Got pretty close too

grave grail
#

Well, I don't cross the boundary outside python usually since I don't know much outside

night quarryBOT
#
Missing required argument

code

#

:white_check_mark: Your 3.13 eval job has completed with return code 0.

Mondziuu: esoteric python
sick hound
#

what in the world

sick hound
#

sorry, was not reacting to u specifically but tihs channel in general

#

seeing the obfuscated code

hybrid trail
hybrid trail
night quarryBOT
#

:white_check_mark: Your 3.13 eval job has completed with return code 0.

Deleted file: /home/main.py
north wraith
#

!e


五, *試験 = [5, 33554431, 18157905, 15255086, 10813998, 8548352, 667904, 151936, 268672, 133568]
レアシンボル, さらに珍しい, はは= "1#", "0.", "025b"
印刷する, 範囲, 地図, 交換する = eval(bytes('牰湩ⱴ爠湡敧‬慭Ɒ猠牴爮灥慬散','u16')[2:])

def 解く():
    印刷する(ね)
    forin 範囲(五):
        印刷する(交換する(交換する(f"{ね:{はは}}"[い*五:-~い*五],*レアシンボル),*さらに珍しい))
    印刷する()

*ψ, = 地図(解く,試験)
night quarryBOT
north wraith
#

the bytes part is "pitónes"

#

||jk||

hybrid trail
#

yet another silly code golf: print the multiples of 8 between 16 and 104, inclusive, in order, each on a single line

#

par is ||27||

grave grail
#

!e|| print(*(i*8for i in range(2,14)))|| 33

quartz wave
#

own line

#

the shortest i've gotten is ||28|| though..

grave grail
#

||for _ in range(2,14):print(_*8)|| ||31||

grave grail
quartz wave
hybrid trail
hybrid trail
#

i tried to make it so that there were a lot of solutions close in byte count :P

arctic skiff
#

!epy 1;while 1:1

night quarryBOT
# arctic skiff !e```py 1;while 1:1```

:x: Your 3.13 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     1;while 1:1
003 |       ^^^^^
004 | SyntaxError: invalid syntax
arctic skiff
#

just use \n it will also count as single char

quartz wave
#

in here it's basically an \n for demonstration purposes only

teal tulip
#

Esoteric Python should be illegal

teal tulip
#

You hear me illegal.

quartz wave
#

is your name samuel seabury, perchance?

teal tulip
fleet lintel
#

!e fun alternate way I just found to make a slice: ```py
from typing import Union
print(Union[1:2:3])

night quarryBOT
earnest wing
#

Oh very good to know for esopy purposes that Union is an identity []function for 1 argument

shy sable
night quarryBOT
quartz wave
#

there's just a few control characters missing from what you wrote

shy sable
quartz wave
#

if written normally those would be \x10 and \x08 respectively

#

!e ```py
*map(print,range(*b'\x10i\x08')),

night quarryBOT
quartz wave
#

!e ```py
print('characters displayed: \x10i\x08')

night quarryBOT
shy sable
#

!e

*map(print,range(*b'i')),
night quarryBOT
quartz wave
#

there.

shy sable
#

The joys of invisible characters.

plush ocean
#

with some small edits to the source code, fixed a thing which was bothering me for a while

#

Also, you know what python lacks? The opposite of id() function

grave grail
#

...
Also why it is 3.15.0a0

#

You cannot just skip pi, make it 3.14.15a9

plush ocean
#

it's a fresh git checkout, aka python from the future

grave grail
#

I didn't know they already started 3.15, nice

plush ocean
#

3.14 is already beta, so whatever you get from git is marked as 3.15 (although in practice it won't be much different from 3.14)

grave grail
#

Try make it 3.14.15a9

subtle viper
#

but how will you deal with garbage ids?

wary python
#

wait

#

no

#
deid(id(2 ** 61))```
#

i can almost guarantee you it wont be 2 ** 61

plush ocean
#

I mean, I already tried that, but that's UB, don't do that

#

("segmentation fault")

wary python
#

deid(2**61)

#

also is that a tsoding tag?? :P

plush ocean
#

yeah, tsoding tag

wary python
#

i wanna see what it gives back

#

like

plush ocean
# wary python deid(2**61)

that's also a segfault (why wouldn't it be unless 2**61 happened to be readable and looking like a pyobject)

wary python
#
a = 2 ** 61
deid(id(a))```
#

that

plush ocean
#
>>> a = 2 ** 61
>>> deid(id(a))
2305843009213693952
wary python
#

oh

#

am i dumb

#

right

#

im mixing things up

#

god im too tired for this

grave grail
#

Which Any would be the pyobject if it exist there

plush ocean
#

I don't think there's a practical way of distinguishing a real pyobject from a random assembly of bytes which happened to look sufficiently like a pyobject

#

in theory you can deid() in the middle of a bytearray and get a pyobject back and then have funny things happen

#

The implementation is literally:

static PyObject *
builtin_deid(PyObject *self, PyObject *args)
{
    long int n;

    if (!PyArg_ParseTuple(args, "l", &n)) {
        return NULL;
    }

    PyObject *ret = (PyObject*) n;
    Py_INCREF(ret);
    return ret;
}
grave grail
#

Then I should rephrase
Just make sure it doesn't segfault

#

If it would segfault if I do deid on the given id, it gives (False, None)

#

Otherwise give (True, object)

#

Whether it would segfault by the usage of such corrupted object can be ignored

plush ocean
#

The only thing deid() cares about is being able to incref, which means being able to read and write this specific location... Not really a strong indication that segfault won't happen right after, e.g. when repr is called

grave grail
#

Oh the segfault was repr? I thought it was when incref

versed eagle
#

if you enable gc debugging

#

that fits some definition of "practical" probably

plush ocean
#

it's not like there's any sane usecase for a function like that 🙂

rugged sparrow
versed eagle
#

i might also be misremembering, its been a couple years since ive looked at the gc lol

rugged sparrow
quartz wave
versed eagle
rugged sparrow
plush ocean
plush ocean
quartz wave
#

this is how i'd write it i think

/*[clinic input]
deid as builtin_deid

    addr: object
    /

Return the object at address addr; may segfault if no object exists.
[clinic start generated code]*/
{
    PyObject *obj = (PyObject *)PyLong_AsVoidPtr(addr);
    if (obj == NULL && PyErr_Occurred()) {
        return NULL;
    }
    return Py_XNewRef(obj);
}
      ...
      BUILTIN_CHR_METHODDEF
      BUILTIN_COMPILE_METHODDEF
+     BUILTIN_DEID_METHODDEF
      BUILTIN_DELATTR_METHODDEF
      ...

then run argument clinic

dull beacon
#

hello! can someone rate my quine program?

line_2 = "    file.write('line_1 = %r\\n' % line_1 + 'line_2 = %r\\n' % line_2 + 'line_3 = %r\\n' % line_3)\n"
line_3 = '    file.write(line_1 + line_2 + line_3)'
with open('quine.txt', 'w') as file:
    file.write('line_1 = %r\n' % line_1 + 'line_2 = %r\n' % line_2 + 'line_3 = %r\n' % line_3)
    file.write(line_1 + line_2 + line_3)```
rugged sparrow
#

!e ```py
print(open(file).read())

night quarryBOT
grave grail
#

Pretty sure the definition of a quine doesn't allow you to read file

rugged sparrow
grave grail
foggy swallow
grave grail
#

Assuming the quine is functional

rugged sparrow
#

!e ```py
exit((:='exit((:=%r)%%)')%)

night quarryBOT
foggy swallow
#

Quines simply have to print their own source code, no?

#

output in some way

grave grail
foggy swallow
#

Correct

#

!e

s = 's = {!r}\nprint(s.format(s))'
print(s.format(s))
night quarryBOT
rugged sparrow
#

!e ```py
='=%r;exit(%%)';exit(%)

night quarryBOT
foggy swallow
hybrid trail
#

A judge for this might look like ```py
with open('./words.txt', 'r') as f:
words = f.read().splitlines()

given_input = open(0).read().splitlines()

assert len(given_input) == len(set(given_input) & set(words)) == 200

#

I honestly have no clue what a good solution is, my best is ||642||

restive void
#

I have ||625|| with a very basic solution

hybrid trail
#

this might be a fun collaborative challenge

#

530
||```py
D=[
'aeaiasatbsckepgsgyicitkelelnmampndnengnknnnyodokoloporpepsptrerkrmrysststtunupur',
'apatceckcododsfeffftinirislklsmpmsnangnkntospepsptrardrerkrmrrrsrtrysesmtsvavevs',
'aoasbabscachckcocsdeefelkoksldlelillmbmemompnanengnknonspsrkrlrmrorprrrtrutitsva',
'ceckcydedodsederesgshiilinitkeldlellltmsnengnknsrdrerkrsrtsmtetsulwlwnwsydyszazz',
'ckdedsdyftgshskakekoktkylelllmltlymamemsndnknspepsrdrerkrnrprtshulvewlwmwnwsyays',
]
for A, B in zip('sto cha chi spa sha'.split(), D):print(A+('\n'+A).join(map(''.join,zip(*[iter(B)]*2))))

hybrid trail
versed eagle
#

how short do we get if we just compress a list of 200 words

#

the words can be chosen for optimal compressing

stable hornet
hybrid trail
versed eagle
#

picking which words to use is an interesting puzzle

#

checking every combination is bad because thats bad

restive void
versed eagle
restive void
#

Also I used base85 to represent the result of that in the code, surely there's better ways.

hybrid trail
#

im thinking it could be possible to store each of the two-letter suffixes in my solution above into one byte

restive void
grave grail
#

I am thinking if there exist >200 word that have the same substring

restive void
grave grail
#

Oh wait I forgot to type
I meant 3

hybrid trail
#

one funny thing i was thinking about you could get longer repeated substrings if you store all of the words concatenated back to back, allowing the last few characters of one word and the next few of another to become some common substring

grave grail
#

And hopefully exist considerably more than 200 so that it can be filtered

restive void
#

I have the compression method down to 551 bytes

fleet lintel
#

Here's my current solution at 398 ||

D="aahederrorallinacherestopeevenallayincellamasassedumboskytesladedalleechedileacharamenemasedgesteadsummahalalamoreechessayontalarmedictalmaserickerneskipsyopposcallanodesextolanchocotestaigapoopsitherondeshireedemangoniflemedinarmethosensewannasalephasteraineembarsoncericingleantardoraddinervenomasananashivespacedargalearedanionicerses";[print(D[(j:=int((5*i-3)/3)):j+5])for i in range(1,201)]

||
Explanation:
||
The strategy is basically "make one giant portmanteau". So far the best compression I've been able to find by brute force is

search_len = ((current_count % 3) == 0) + 3
if current[-search_len:] == word[:search_len]:
    stack.append((current_count + 1, current + word[search_len:], (*current_trace, word)))

This turns out to make https://oeis.org/A047212 , or gaps of 2 2 1 2 2 1 2 2 1 between word starts. There is probably a more concise way to generate the i but I've literally spent hours on this one part so I just gave up and used a definition from OEIS.
Trying to do a pure length 4 search_len fails. I'm unsure if % 2 works yet, my code is too slow.
||

hybrid trail
#

🤯 I like the idea

#

you can bring it down to 386 with some simple golfs. It's a creative idea!
||```py
for i in range(200):j=(5*i+2)//3;print("aahederrorallinacherestopeevenallayincellamasassedumboskytesladedalleechedileacharamenemasedgesteadsummahalalamoreechessayontalarmedictalmaserickerneskipsyopposcallanodesextolanchocotestaigapoopsitherondeshireedemangoniflemedinarmethosensewannasalephasteraineembarsoncericingleantardoraddinervenomasananashivespacedargalearedanionicerses"[j:j+5])

versed eagle
#

we may as well check

restive void
versed eagle
#

aha

#

all the way up there

#

thanks

fallen hound
#

brother this chat has war crime level code and thats in python 😭

fleet lintel
# hybrid trail http://golf.horse/ results indicate that an optimal solution might be <200 bytes

I’ve been thinking about this, and I suspect there’s one key difference: because the amount of data is so much larger there, it will almost always be worth it to trade processing complexity for compression space. With how much less data there is here, a lot of the fancy tricks probably won’t work because they have too much overhead. The actual data compression limit might be around 200 bytes, but my guess is that would make the decompression algorithm way too complex to fit into the saved space.

hybrid trail
#

that makes sense

grave grail
#

Are there any chance we could find combinations of data and rely built-in libraries to decompress

#

Using external (i.e. stdlib) is way better than what we could possibly do with less overhead

somber obsidian
#

!e ```py
___: int = 1--+------+-++-++----+---++-+--+--1-+--1
_: str =1--+------++1+-+-+--+-+-++-++--++---1-+1
____: float = 1-----+-++++---+---1---++--+---+1
__:int=1--+------+-++-++--1---+---++-+--+--1-+--1

this is 1+2+3

_____ = +-+++--+--++--++--+-+-+--++-++_+-+++--+--++--++--+-+-+--++-+_+____

print(_____)

night quarryBOT
rich lagoon
#

!eval ```py
print(-~1)

#

!e```py
print(-~1)

night quarryBOT
rich lagoon
#

!e

import operator as op

class Op:
    from operator import *

assert op.add is Op.add
print(dir(Op))
rich lagoon
#

!e```py
import operator as op
import functools as ft
import itertools as it
import random

inc = lambda n: -~n
dec = lambda n: ~-n
odd = lambda n: bool(n&1)
even= lambda n: odd(dec(n))
mul4= ft.partial(op.mul, 4)

def N(n, r):
if r in {0, n}:
return 1
return N(n-1, r-1) + N(n-1, r)

n = op.itemgetter(1)(divmod(1001, 35))
f = filter(odd, range(5, 100, 3))
m = map(op.itemgetter(-2), map(list, map(range, f)))
r = random.choice(list(m))

print(N(n, r))

night quarryBOT
# rich lagoon !e```py import operator as op import functools as ft import itertools as it impo...

:x: Your 3.13 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 22, in <module>
003 |     print(N(n, r))
004 |           ~^^^^^^
005 |   File "/home/main.py", line 15, in N
006 |     return N(n-1, r-1) + N(n-1, r)
007 |            ~^^^^^^^^^^
008 |   File "/home/main.py", line 15, in N
009 |     return N(n-1, r-1) + N(n-1, r)
010 |            ~^^^^^^^^^^
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/YBUNGD2T3LGCA7MQ56MCHC5CT4

rich lagoon
#

!e

import operator as op
import functools as ft
import itertools as it
import random

inc = lambda n: -~n
dec = lambda n: ~-n
odd = lambda n: bool(n&1)
even= lambda n: odd(dec(n))
mul4= ft.partial(op.mul, 4)

def N(n, r):
  if r in {0, n}:
    return 1 
  return N(n-1, r-1) + N(n-1, r)

def __main__():
  n = random.choice( divmod(999, inc(35)) )
  f = filter(odd, range(5, 100, 3))
  m = map(op.itemgetter(-2), map(list, map(range, f)))
  r = random.choice(list(m)) % n
  print(N(n, r))

locals()[__name__] is __main__ and __main__()
night quarryBOT
rich lagoon
#

!e```py
import functools as ft
import operator as op

mul2 = ft.partial(op.mul, 2)

mul2(11) == 22 and print(ft.partial.name, name[3:-2].replace(*'ay'))

raven rampart
#
class R:
    def _endless(start, step):
        curr = start

        while True:
            yield curr
            curr += step

    def _forwards(start, step, end):
        curr = start

        while curr <= end:
            yield curr
            curr += step

    def _backwards(start, step, end):
        curr = start

        while curr >= end:
            yield curr
            curr += step

    def better_range(start, step, end=None):
        if end is None:
            return R._endless(start, step)
        elif step > 0:
            return R._forwards(start, step, end)
        else:
            return R._backwards(start, step, end)
            
    def __class_getitem__(cls, args):
        start = args[0]

        if args[1] is ...:
            # Default stepsize
            try:
                end = args[2]
            except IndexError:
                end = None

            step = 1 if end is None or start <= end else -1
        elif args[1] is not ...:
            # Stepsize provided
            assert(args[2] is ...)

            try:
                end = args[3]
            except IndexError:
                end = None

            step = args[1] - start

        return R.better_range(start, step, end)



for x in R[0, ..., 10]:
    print(x)

for x in R[0, 2, ..., 10]:
    print(x)

for x in R[10, 8, ...]:
    print(x)
#

Any ideas for the syntax?

#

I'd love to be able to include inclusive/exclusive ranges somehow that's close to math, like R[0, ..., 4)

#

but obviously this is probably not really possible

restive void
#

R[0, ..., 4, ")"] :P

raven rampart
#

ewww

#

maybe a wrapper class that wraps numeric types

#

R[0, ..., exclusive(4)]

#

obviously I can easily define a completely exclusive interval

#

like

R(0, ..., 4)

#

the half open ones are the problems

#

maybe it's time for a pep

#

to allow for a mutated __getitem__ and __call__ amalgamation

#
    def _make_exclusive(generator):
        generator.__next__() # throw away the first value

        prev_val = generator.__next__()
        
        # this throws away the last value
        for val in generator:
            yield prev_val
            prev_val = val

    def __new__(cls, *args):
        return R._make_exclusive(R[args])



for x in R(10, 8, ..., -2):
    print(x)
#

it's taking shape

earnest wing
arctic skiff
earnest wing
#

inaccessibility wins

hybrid trail
#

Could you make for I in (0 < R <= 10)

raven rampart
#

Hmmmm this is not bad at all

raven rampart
earnest wing
raven rampart
#

Need to run a background process to make sure it always points to my object

stable hornet
#

!e ```py
class _R:
def init(self): self.l = self.u = None
def ge(self, o):
self.l = o
return self
def gt(self, o): return o + 1 <= self
def lt(self, o):
self.u = o
return self
def le(self, o): return self < o + 1
def iter(self):
if self.l is None or self.u is None: raise ValueError('provide upper and lower bounds')
it = iter(range(self.l, self.u))
self.l = self.u = None
return it
def repr(self): return f'{self.l} <= R < {self.u}'
R = _R()

for n in 0 < R <= 3:
print(n)

print(list(1 <= R < 11))

night quarryBOT
earnest wing
#

oh wait you're right! I was thinking of __bool__ and how comparison chaining implicitly calls and, but the short circuiting cancels that out

#

that does work!

grave grail
#

Challenge: make multi-bound possible
Like (1 < R <= 20 and 0 < R <= 10) or (1 < R <= 20 or 29 < R <= 37)

earnest wing
#

ambiguous without stack frame inspection

grave grail
#

not really? Unless I remember wrong and you cannot manipulate the output of A or B given A/B is controlled by the developer

#

oops, there are actually isn't

#

*Like ((1 < R <= 20) & (0 < R <= 10)) or ((1 < R <= 20) | (29 < R <= 37))

#

I am sure bitwise and/or would actually be overrideable, instead of syntax one

earnest wing
earnest wing
grave grail
#

hmm, then it cannot be calculated if I do like 1 < R <= 10000000000000000000

versed eagle
versed eagle
#

((1 <= R) & (2 <= R))

#

cant be a set without some sort of further trickery going on

grave grail
#

it mean, if you do (R < 1), it would break anyway
unless it doesn't have to retain a specific order

fleet lintel
# grave grail Are there any chance we could find combinations of data and rely built-in librar...

I have come up with a way to do this, but I don't have the ability to do it (where "this" is the output 200 wordle words challenge #esoteric-python message using builtin things):
Theoretically this should make a valid solution (not golfed for clarity): ```py
import random, itertools
random.seed(<seed>)
[print(word) for word in random.sample(itertools.permutations(['a', 'e', 'i', 'l', 'p', 'r', 's', 't'], 5), 200)]

The idea of this is that the length 5 permutations of the characters `['a', 'e', 'i', 'l', 'p', 'r', 's', 't']` make 245 valid wordle words. I found this character set using a different brute force program.
Since you can set the seed `random` uses, you should be able to find a seed where the first 200 samples of `random.sample` produce only the wordle words. This is very unlikely, since there are 6720 permutations, but it should be possible. Brute force won't work (I tried, you'd have to check 10^96 seeds), but given that the [Seed esolang](https://esolangs.org/wiki/Seed) exists which is also based on a Mersenne twister (like the `random` module), it should be possible to reverse the desired output into a seed, making for an extremely short solution.
The main issue is that I have completely failed to understand any of the reversing algorithms, or how they would be applied to this case. Hopefully someone else here has that required knowledge to complete the golf.
hybrid trail
#

would 10^96 possibilites mean the hash should be around log_2(10^96) = 320 bits of information, or around 40 bytes long?

fleet lintel
#

Maybe? I’m not 100% sure how hashes translate to the twister state, but you can set it directly so I guess it could also depend on that? The 10^96 comes from getting up to 24 words brute forcing from seed 0, then doing an exponential regression

earnest wing
#

in theory the total proportion of random samples of letter permutations that form 200 unique wordle words is given by
P(245, 200) / P(P(8, 5), 200) ~~ 10^-340
but with mersenne twister i think most of those sequences simply do not occur and you saturate the random state

fleet lintel
#

But doesn’t the twister have a period of 2^19973-1, or about 10^6001?

fleet lintel
#

I managed to find a sequence of 200 state inputs such that if you set the state to that + index 0, it does generate the 200 words. All the numbers are also relatively low (<10 million), so there are definitely a ton of working states. Still no clue how you could reverse that into a valid seed, since when using random.seed index is set to 646 so it instantly does a twist, and currently setting the 200 states is way longer than the portmanteau solution.

sage lintel
subtle viper
night quarryBOT
subtle viper
#

!e also works with the expression part itself ```py
fs = [i := (j, lambda: i) for j in range(3)]
i = 7
print(fs[1]1)

night quarryBOT
sage lintel
#

i haven't really ever used the walrus in python

stray grove
#

I didn’t even get it until i asked an AI

stray grove
lament pond
#

someone give me a program that prints the string "hi"

stray grove
hybrid trail
lament pond
lament pond
quartz wave
quartz wave
quartz wave
hybrid trail
quartz wave
#

...or you can interpret it that way

quartz wave
# lament pond Soynds good. How exactly do you do this?

!e ```py
z=[0]*2
while'a'[:z[0]==ord('h')<ord('i')==z[1]]<'0':z[0]+=b'h'[0]^z[0]>0;z[1]+=b'i'[0]^z[1]>0
print("".join(chr(0x16a0+b"fvufyfvuafvuyafvurcfkfvgfwhfvunfvifjfvuypzfsfvutfvbfvuemfvlfvudofvuyarckgqx".index(z|b' '[0]))for z in z))

night quarryBOT
proper vault
#

!e

import random
random.seed(0x37abe)
print("%c%c" % (random.randrange(256), random.randrange(256)))
night quarryBOT
magic wraith
#

!e ```py
print(
print
.self
.dir()
.getitem(121)
.getitem(slice(1,3))
)

night quarryBOT
whole patrol
#

wait what is this channel about

magic wraith
#

read the channel description

whole patrol
#

i read it

#

didn't help ;-;

grave grail
whole patrol
#

okay... Black magic

austere mauve
#

(Note that sharing solutions before the deadline is frown-upon)

sage lintel
#

not sure why that needs to exist tbh

bright valve
#

I've been thinking quite a while about making a script that instead of using another file as storage, it uses itself

#

shitcode but it works lol

with open(__file__) as f:
    lines = f.read().strip().split("\n")
    start = lines.index('"""')
    names = lines[start+1:-1]

print(names)

while True:
    name = input(":")
    if not name:
        lines = lines[:start]
        lines.append('"""')
        lines.extend(names)
        lines.append('"""')

        with open(__file__, "w") as f:
            f.write("\n".join(lines))
            
        exit()

    names.append(name)
"""
"""
#

could even store an sqlite db in here

#

maybe save the file on the script, when the script is ran create it again, save and delete

#

idk if it might be possible to create a sqlite database from bytes

magic wraith
night quarryBOT
# magic wraith !e you could store in the bytecode then marshal this into a .pyc ```py c = compi...

:x: Your 3.13 eval job has completed with return code 1.

001 | <code object <module> at 0x7f7395c3cd50, file "", line 1>
002 |   0           RESUME                   0
003 | 
004 |   1           LOAD_CONST               0 (3)
005 |               STORE_NAME               0 (a)
006 |               RETURN_CONST             1 (None)
007 | Traceback (most recent call last):
008 |   File "/home/main.py", line 6, in <module>
009 |     dis.dis(new_c)
010 |     ~~~~~~~^^^^^^^
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/67PNRPBVIWPTI75EBEVCHIZNWA

magic wraith
night quarryBOT
#

Objects/codeobject.c lines 472 to 482

if (PyBytes_GET_SIZE(con->code) > INT_MAX) {
    PyErr_SetString(PyExc_OverflowError,
                    "code: co_code larger than INT_MAX");
    return -1;
}
if (PyBytes_GET_SIZE(con->code) % sizeof(_Py_CODEUNIT) != 0 ||
    !_Py_IS_ALIGNED(PyBytes_AS_STRING(con->code), sizeof(_Py_CODEUNIT))
    ) {
    PyErr_SetString(PyExc_ValueError, "code: co_code is malformed");
    return -1;
}```
cerulean wadi
#
الرقم_الأول = float(input("أدخل الرقم الأول: "))
الرقم_الثاني = float(input("أدخل الرقم الثاني: "))

المجموع = الرقم_الأول + الرقم_الثاني

print("المجموع هو:", المجموع)```
sage lintel
#

المجموع هو: 16.0

cerulean wadi
sage lintel
#

it works

cerulean wadi
#

Yeah lol someone shared Python in Chinese xD

sage lintel
#

i'm very tempted to use this in the next program i send to someone

fair oak
sage lintel
#

i don't think it does

sage lintel
#

i should send them a program like this

cerulean wadi
#

lol

fair oak
#

That's neat

ruby gulch
cerulean wadi
quartz wave
cerulean wadi
#

x = [0,0,[]]
0 and [] means False?

quartz wave
cerulean wadi
#

Wdym?

quartz wave
# cerulean wadi Wdym?

!e ```py
print(f"{0 == False = }")
print(f"{[] == False = }")

if 0:
print("zero is truthy")
else:
print("zero is falsy")

if []:
print("[] is truthy")
else:
print("[] is falsy")

night quarryBOT
sage lintel
quartz wave
#

but [] is not

sage lintel
quartz wave
#

0 is not False and [] is not False
0 == False but [] == False
but 0 and [] are both falsy, i.e. when you turn them into a boolean, they return False

cerulean wadi
#

Do you know them?

quartz wave
quartz wave
cerulean wadi
cerulean wadi
#

I mean in logic

quartz wave
#

!e not simply inverts the result of the boolean ```py
print(not False)
print(not True)

night quarryBOT
cerulean wadi
#

0 means false and 1 is true

#

I know not

#

I meant not()

quartz wave
cerulean wadi
#

!e print(not())

night quarryBOT
cerulean wadi
#

Huh?

quartz wave
cerulean wadi
sage lintel
#

what in the hell is that

#

oh

cerulean wadi
#

bro 0 in Python is TRUE?

#

WHAT?

quartz wave
#

() is an empty tuple

cerulean wadi
#

Yeah

quartz wave
#

not is an operator

#

not() is an operation on an empty tuple

cerulean wadi
#

Yeah not * anything is the opposite

quartz wave
#
empty tuple
   vv
not()
^^^
operator
sage lintel
#

!e if():
pass
else:
print("this is weird")

night quarryBOT
quartz wave
cerulean wadi
#

empty tuple is false

quartz wave
night quarryBOT
cerulean wadi
#

Bro False != Falsy? just to understand

quartz wave
cerulean wadi
#

What's it then?

quartz wave
#

just because it's falsy doesn't mean it's False

cerulean wadi
#

What's the mean Falsy?

quartz wave
cerulean wadi
#

oh

quartz wave
#

so when you call bool() on it, it returns False

sage lintel
night quarryBOT
# sage lintel !e ```py print(0 is False) ```

:white_check_mark: Your 3.13 eval job has completed with return code 0.

001 | /home/main.py:1: SyntaxWarning: "is" with 'int' literal. Did you mean "=="?
002 |   print(0 is False)
003 | False
cerulean wadi
#

xd

quartz wave
#

if and while internally call bool() on things too

cerulean wadi
#

Opposite of falsy is truely?

sage lintel
#

truthy

quartz wave
cerulean wadi
#

huh

#

So falsy has a value

#

But in the origins it's false right?

quartz wave
#

no

cerulean wadi
#

??

quartz wave
#

the boolean value is false, the original value is not

#

the original value of [] is the list itself, and its boolean value is False

cerulean wadi
#

oh

quartz wave
#

the boolean value is not the origin

sage lintel
#

those statements are the same i think

quartz wave
cerulean wadi
#

oh

#

and also () is false

sage lintel
#

falsy

#

not false

#

:p

cerulean wadi
#

😭 Someone said empty tuple is false

sage lintel
#

they probably meant it's falsy

quartz wave
#

empty python things are usually falsy

cerulean wadi
sage lintel
#

!e print( bool( () ) )

cerulean wadi
#

Look

quartz wave
#

like (), [], ""

#

they're falsy

cerulean wadi
#

So, it's false

night quarryBOT
sage lintel
#

ugh is () even "falsy"?

quartz wave
#

!e ```py
if () == False:
print("() is False")
else:
print("() is a falsy object")

night quarryBOT
sage lintel
#

is "falsy" defined via == or via bool()?

quartz wave
sage lintel
#

ah

sage lintel
quartz wave
#

but it's confusing to just print the result bool()

quartz wave
#

False is an instance of bool, 0 is an instance of int

sage lintel
quartz wave
#

python considers them equal along with 0.0 and -0.0 (from float), but they're not the same object

sage lintel
#

they also test if () is a different type of falsy

quartz wave
#

!e ```py
if () is False:
print("() is False")
else:
print("() is a falsy object")

night quarryBOT
sage lintel
#

is, ==, and bool() can all be different

cerulean wadi
#

print(not(False),not(True),not(None),not(tuple()),not())

#

True false true true true

sage lintel
#

not will always make it the opposite

cerulean wadi
#

Yeah

#

But falsy is not false then it's true?

sage lintel
#

it can be neither

#

0 is a number (and is falsy)

cerulean wadi
#

😭 When it becomes true or false??

sage lintel
#

True and False are not numbers

cerulean wadi
#

But 0 in bool is false

sage lintel
#

0 is neither True or False

cerulean wadi
#

Huh

quartz wave
#

is for identity equality (i.e. memory address is equal), == for comparative equality (i.e. using __eq__), bool() for getting the boolean value (i.e. truthy or falsy)

sage lintel
quartz wave
#

0 itself is not False

#

but python considers them equal using ==

#

True == 1 and False == 0, but that doesn't mean 1 is True and 0 is False

cerulean wadi
#

That's strange for me

#

everywhere 0 is false is 1 is true

quartz wave
#

0/1 are ints
False/True are bools

#

!e ```py
print(0 == False)
print(f"{type(0) = }")
print(f"{type(False) = }")

night quarryBOT
cerulean wadi
#

True

#

Look

#

That means it's false

quartz wave
#

it's not False

cerulean wadi
#

.-.

quartz wave
#

it's equal to False

cerulean wadi
#

I mean

#

Used in bool as false

sage lintel
#

i believe there's only one "False" value in python. (if you have a list of many Falses, the list just holds many copies of the same reference to the same place in memory - hope i worded that right)
similarly, there's only a single 0 value in python. and it's a different value than False
then, you can just decide the output of comparing them using == or applying bool()

#

they are different values, but doing 0 == False can still output True

cerulean wadi
#

In Binary and C++ and most of the languages 0 is treated in boolean as false

quartz wave
#

so python inherits the fact that 0 is equal to False

#

but 0's type is int, and False's type is bool

cerulean wadi
#

That's what I am talking about ;-;

#

I know 0 is int bro

sage lintel
#

0 is int means 0 is not False

#

because False is not int

cerulean wadi
#

I mean in the output

#

When it's false it outputs 0

#

in C++

#

and BIN

#

and some other langs

sage lintel
#

ceweal meant 0 is an int in python

#

but ok i see what you mean

fair oak
#
### Helps with help command ###

مساعدة="help"

help("".join((lambda x=ch: x)() for ch in مساعدة))

austere mauve
# cerulean wadi and some other langs

And in python every object (including those that you'd treat as fundamental) is a struct.
Treat True and False as special singletons that python distinguishes for conditional operations. Additionally python knows how boolean values are implemented in eg.: C, so it pretends that booleans are similar to integers: issubclass(bool, int) -> True; True + True == 2, ....
But if booleans / integers were fundamental objects in python, something like this wouldn't be possible:

#

!e ```py

A hack for circumventing class protiection implemented by python interpreter

class A:eq=lambda s,o:o
(bool.dict==A())["fictional_attr"] = "Hello World!"

print(True.fictional_attr)

night quarryBOT
fair oak
night quarryBOT
# fair oak !e ```python ### Helps with help command ### مساعدة="help" help("".join((lambd...

:white_check_mark: Your 3.13 eval job has completed with return code 0.

001 | Help on _Helper in module _sitebuiltins object:
002 | 
003 | help = class _Helper(builtins.object)
004 |  |  Define the builtin 'help'.
005 |  |
006 |  |  This is a wrapper around pydoc.help that provides a helpful message
007 |  |  when 'help' is typed at the Python interactive prompt.
008 |  |
009 |  |  Calling help() at the Python prompt starts an interactive help session.
010 |  |  Calling help(thing) prints help for the python object 'thing'.
... (truncated - too many lines)

Full output: https://paste.pythondiscord.com/PKPZKUO3E2ZTF6YBSTNCXWCDJA

old bronze
#

!e

print([None] * 1000])
night quarryBOT
# old bronze !e ``` print([None] * 1000]) ```

:x: Your 3.13 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     print([None] * 1000])
003 |                        ^
004 | SyntaxError: closing parenthesis ']' does not match opening parenthesis '('
old bronze
#

!e

print([None] * 1000)
night quarryBOT
# old bronze !e ``` print([None] * 1000) ```

:white_check_mark: Your 3.14 pre-release eval job has completed with return code 0.

[None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, Non
... (truncated - too long)

Full output: https://paste.pythondiscord.com/PBMP7RUII6AKHWQPLWAOQXAKUE

north wraith
#

||jk||

cerulean wadi
#
print(''.join(map(chr, [72,101,108,108,111,44,32,119,111,114,108,100,33])))
#

!e print(''.join(map(chr, [72,101,108,108,111,44,32,119,111,114,108,100,33])))

night quarryBOT
cerulean wadi
#
_ = lambda __ : __()
__ = lambda : chr(72)+chr(101)+chr(108)*2+chr(111)+chr(44)+chr(32)+chr(119)+chr(111)+chr(114)+chr(108)+chr(100)+chr(33)
_(__)```
#

!e _ = lambda __ : ()
__ = lambda : chr(72)+chr(101)+chr(108)*2+chr(111)+chr(44)+chr(32)+chr(119)+chr(111)+chr(114)+chr(108)+chr(100)+chr(33)
_(
)

night quarryBOT
versed eagle
versed eagle
#

which is cute

quartz wave
#

signed 1-byte value

austere mauve
night quarryBOT
austere mauve
#

(abusing two's complement)

tiny gate
#

!e
print(~True)

night quarryBOT
tiny gate
#

What

arctic skiff
#

True is 1 or 0b0000_0001(assume 8 bit signed integer for example) in binary, bitwise not turns it into 0b1111_1110 which is -2

#

same for False, which is 0 or 0b0000_0000 and bitwise not turns it into 0b1111_1111 which is -1

tiny gate
#

So the ~ makes it not? I dont understand

#

Why so you do ~

arctic skiff
tiny gate
#

i do already know them

#

they're just like the ones from boolean algebra

#

not, or, and, xor

grave grail
#

bitwise mean the operation apply on each bit

tiny gate
#

Yeah

grave grail
#

And do you know two's complement?

tiny gate
#

i almost remember it from a redstone video from minecraft, i think its like an algorithm with bytes?

#

mainly used for addition and subtraction i think

cerulean wadi
#

Tyy

cerulean wadi
#

uh man this channel is for mad people finding crazy things

restive void
#

So part one of the weirdness is: True is equal to 1, and False is equal to 0.

#

Then you look at the binary representation of 1 and 0, and look at what happens (w.r.t. two's complement) when you flip each bit.

cerulean wadi
#

Isn't ~ means not?

restive void
#

Yeah, but not is not the same as ~.

#

No

#

~ is bitwise not.

cerulean wadi
#

💀 My whole life was a lie

restive void
#

!e

x = 7
print(bin(x))
print(bin(~x))
night quarryBOT
cerulean wadi
#

Wait

#

Is this the position in RAM?

restive void
#

well, that's not very helpful

#

It's how the number would be represented in two's complement, which is what Python's ints are based on. Sort of.

cerulean wadi
#

ohh I got it so the number system of Python made with Binary System?

restive void
#

Yes. ints with a different binary encoding than floats, but yes, in the end every value must be encoded in binary, because that's how computers work.

cerulean wadi
#

Yeah that's why I won't join AI field even if I die

cerulean wadi
restive void
cerulean wadi
#

ok

sharp kiln
#

hi everyone

obtuse hazel
#

context: #python-discussion message

Asked claude and it suggested using type, so I did this to test, which works, but there's still something wrong, the keybind works as expected, but it doesn't show up in the footer, it ought to, so I think there's still something I'm missing when using type, probably in the dict?

from collections.abc import Callable

from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.screen import Screen
from textual.widgets import Footer


def include_bindings[T: Screen | App](field: str) -> Callable[[type[T]], type[T]]:
    # build a bindings list from settings, hardcoded it for testing
    bindings = [Binding("w", "quit", show=True)]

    def wrapper(cls: type[T]) -> type[T]:

        NewClass = type(
            cls.__name__,
            (cls,),
            {
                "BINDINGS": bindings,
                "__module__": cls.__module__,
                "__qualname__": cls.__qualname__,
            },
        )

        return NewClass

    return wrapper


@include_bindings("")
class Test(App):
    def compose(self) -> ComposeResult:
        yield Footer()

    def on_mount(self):
        self.notify(str(self.active_bindings.keys()))


if __name__ == "__main__":
    Test().run()
arctic skiff
#

run before your code get turned into a golf ball

obtuse hazel
arctic skiff
#

fair

arctic skiff
#

or just pass "Quit" as third positional argument to Binding

#

and show default value is True

obtuse hazel
#

oh yeah I'm dumb

#

I knew it, but I just forgot 💀

#

well, that was anticlimactic

#

into the void of useless info it goes

modest bough
rugged sparrow
subtle viper
#

(there's no __req__())

rugged sparrow
#

yea, so the comparefunc falls back on using the second arg (A())'s __eq__ with the mapping proxy's wrapped dict as the argument

#

because mappingproxy richcompare just calls richcompare on its wrapped dict

night quarryBOT
#

Objects/descrobject.c lines 1232 to 1240

static PyObject *
mappingproxy_richcompare(PyObject *self, PyObject *w, int op)
{
    mappingproxyobject *v = (mappingproxyobject *)self;
    if (op == Py_EQ || op == Py_NE) {
        return PyObject_RichCompare(v->mapping, w, op);
    }
    Py_RETURN_NOTIMPLEMENTED;
}```
rugged sparrow
#

RichCompare tries to compare ->mapping (dict) with w (A()) and fails with dict.__eq__, so it falls back on using A().__eq__

rugged sparrow
subtle viper
#

and that.. segfaults-?

rugged sparrow
#

directly mutating it violates rules with the attribute cache

#

so it can cause weird errors when the attribute cache is in one state for the class, and the actual backing storage is in another state

night quarryBOT
#

fishhook/fishhook.py lines 141 to 143

getdict(type)['__base__'] = __base__
# call PyType_Modified to reload cache
pythonapi.PyType_Modified(py_object(type))```
rugged sparrow
#

to make the attribute cache sane again, you need to call PyType_Modified (which actually just invalidates the cache entirely)

night quarryBOT
#

small_hook.py lines 37 to 45

def PyType_Modified(cls):
    cls_mem = getmem(id(cls), sizeof(cls), 'P')
    flags = cls.__flags__
    flag_offset = [*cls_mem].index(flags)
    if not cls.__flags__ & Py_TPFLAGS_VALID_VERSION_TAG:
        return
    for subcls in type(cls).__subclasses__(cls):
        PyType_Modified(subcls)
    cls_mem[flag_offset] &= ~Py_TPFLAGS_VALID_VERSION_TAG```
modest bough
#

or it's that req taps directly into cpython structs and i managed to assign something wrong into an object field

#

ah I didn't see the discussion above. reading now

austere mauve
modest bough
#

funny, different os and build though

magic wraith
#

works on ubuntu 24.04 for me```py
Python 3.12.3 (main, Jun 18 2025, 17:59:45) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

class A:eq=lambda s,o:(s,o)
...
(bool.dict==A())[1]['doc'] = "A natural number"
help(True)

(it makes interactive ui that i can scroll up and down)

arctic skiff
#
Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb  4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> class A:__eq__=lambda s,o:(s,o)
...
>>> (bool.__dict__==A())[1]['__doc__'] = "A natural number"
>>> help(True)
E:\co>     ```
#

exit code is -1073741819

arctic skiff
#

considering that it does crash on 3.13.2 and 3.13.5, and doesn't crash on 3.12.9, 3.12.3, 3.13.1

#

its bug since 3.13.2

#

interesting

modest bough
#

wow, in all this foolery we're maybe uncovering a real bug

arctic skiff
#

you do realize that 90% of bugs in "interpreters" comes from esoteric code?

modest bough
#

sorry i didn't mean it as an insult, i like trying to poke around language construct in all possible ways

arctic skiff
#

wait

arctic skiff
modest bough
#

but it's the first time i witness a potential bug being discovered like htat

modest bough
arctic skiff
modest bough
#

that's out of my league but maybe when the assigned string can exist in the right spot / page sometimes and forbidden some other times

arctic skiff
#

and now somehow crashed on 3.12.9

modest bough
#

heisenbug

arctic skiff
#
'help(True)'
>>>```
#

how did it become help(True)

modest bough
#

I saw something similar yesterday

#

at one point I think the docstring from another type got used instead

#

maybe there's some hashing creating cache collisions

arctic skiff
#

ok

#

so here it is

#

I got it

#

kinda

#

so

#

it breaks on running help after second time you reassign it but only if you run help before the 2nd reassign

#

which is weird

#

¯_(ツ)_/¯

#

the bug itself is kinda weird

rugged sparrow
arctic skiff
#

whats the actual bug and where is the report?

rugged sparrow
#

And yes, it's gonna be behave different on different system, because the allocations might be in different orders or laid out differently

rugged sparrow
arctic skiff
#

it does seems like a memory bug

rugged sparrow
#

This would be a logic bug tbh I think

#

Although the attribute cache inconsistency could be seen as a memory bug

quartz wave
#

i've been searching through Objects/typeobject.c to know where but i just can't figure it out..

#

PyType_Modified sets a flag (how does that reset?), getting/setting .__doc__ has descriptors but i don't see how modifying the dictionary can make it segfault-

rugged sparrow
modest bough
#

interesting comments too, TIL

rugged sparrow
modest bough
#

fuzzes cpython manically

quartz wave
magic wraith
rugged sparrow
modest bough
#

not too far from Proxy uses in other languages (js, java,. ..)

unborn thistle
#

I am French and on Visual Code Studio I cannot install Selenium in my terminal. Could someone translate everything into French in a private message please?

ember shale
#

I want all Python language commands

#

Or frequently used important commands

earnest wing
#

exec is the most important and next is globals. from there everything else is simple

magic wraith