_whitelogger has joined #pypy
<dstufft> arigato: Ok, feel free to revert the patch then, I am just dumb :)
<graingert> arigato: it's pretty reliable, https://pypi.org/project/patchy
<arigato> no problem :-) I'll leave the patch in anyway, to avoid redefinition if somebody really sets it too
<graingert> arigato: just need to work out the magic that makes PyPy behave the same
<arigato> graingert: dig inside CPython's ast compiler to figure out the ordering of "free" variables, and then dig inside PyPy's ast compiler to figure out if and why it is different
<antocuni> graingert: patchy looks both interesting and horrifying at the same time :)
<graingert> antocuni: it's the best
<graingert> a bit dodgy on pypy though
<arigato> cpython seems to sort the free variables alphabetically
<graingert> CPython lets do do fun stuff like: https://www.irccloud.com/pastebin/iRekHKCJ/foo.py
<graingert> and because freevar_a and _b exist and are in the function body, the body picks them up
<graingert> but you have to pretend harder to use them
<antocuni> graingert: sure, PyPy does the same. The only difference is the *ordering* of them inside the code object
<graingert> antocuni: what do you mean by that?
<graingert> oh no I understand
<graingert> so what controls the ordering
<antocuni> arigato said that on CPython it seems to be always alphabetical; on PyPy, I guess it depends on where they appear in the AST
<arigato> I think CPython sorts co_freevars and co_cellvars
<arigato> pypy doesn't do that
<arigato> it was changed for CPython 3.2 in issue #15368
<arigato> either with no test, or with tests that we didn't look at so far
<arigato> (I think the choice #1 is more likely)
<arigato> graingert: in summary, your code would break on CPython 2.7 too
<arigato> which you may not care about :-)
<arigato> but it helps explain why we didn't find this problem already
<graingert> arigato: not it works on CPython 2.7
<graingert> no*
<graingert> because I define the slots in the order they are in co_freevars
<arigato> but the order in co_freevars is random
<graingert> I don't think it's random
<graingert> I think it's the order they are defined
<graingert> or something
rowillia has joined #pypy
<arigato> well, this order changed between CPython 2.7 and CPython 3.x
<graingert> oh that's fine
<graingert> I'm not planning on pickling a py27 __code__ and pulling it out in py36
<graingert> yet...
<arigato> that's not what I'm saying
<rowillia> Howdy! I'm super new to PyPy and wanted to start debugging https://bitbucket.org/pypy/pypy/issues/2533/error-in-ctypes-when-using-rtree. Is anyone familiar with ctypes in PyPy that can point me in the right direction to start?
<antocuni> graingert: that test is not really meaningful: it has 50% of probability to work by chance, if the order is random or not well defined. It should contain many more variables with random names to be more robust
<graingert> antocuni: probably, but it's never failed in many runs
<graingert> antocuni: can you think of a more reliable way of bodging the freevars?
<antocuni> graingert: the most reliable is to look at CPython source code to check what it does, instead of guessing :)\
<graingert> hmm, I don't feel that's the patchy way
<arigato> ...ok, no clue
<antocuni> it seems that the exact order of freevars in the code object depends on the order of them in the internal dictionary used by the compiler
<arigato> trying out, it seems that CPython 2.7 and 3.5 give the same results, and occasionally pypy a different one
<arigato> but the sorting logic is only in 3.5
<antocuni> which basically means that you cannot write a reliable way to do what you want
<arigato> this is a different result:
<LarstiQ> rowillia: can you minimize that snippet a little further?
<graingert> arigato: but on PyPy the dict should be ordered
<arigato> it doesn't matter
<graingert> ?
<arigato> there are no dicts around
<arigato> only a few ones used internally
<arigato> and their order doesn't matter
<graingert> arigato: so the dict_keys_inorder fn doesn't matter?
<antocuni> arigato: it seems to matter on CPython 2.7 though, see the link I pasted above
<arigato> I think CPython 3.x added alphabetical ordering of co_freevars for no reason I understand, because previously the order is deterministic too
<graingert> arigato: is the order deterministic or not?
<arigato> antocuni: no, note that the order of iteration inside dict_keys_inorder() doesn't change anything
<arigato> it just changes the order in which the items of the new tuple are filled,
<rowillia> LarstiQ: I played around with it quite a bit and unfortunately I've gotten a bit lost in how ctypes work in PyPy. The core of the issue is in assigning to `p_mins[0]` (type(p_mins) is `<class '_ctypes.pointer.LP_LP_c_double'>`)
<arigato> but they will end up the same
<rowillia> type(p_mins[0]) is <class '_ctypes.pointer.LP_c_double'>
<LarstiQ> rowillia: what should the value of dimensions be?
<LarstiQ> rowillia: the snippet isn't runnable as is?
vkirilic_ has quit [Remote host closed the connection]
<rowillia> LarstiQ: I have it in a debugger now, `dimension` is 2
<arigato> antocuni: ah, but dictbytype(), called earlier, is dict-order-dependent
<arigato> it depends on the order of another dict, which contains all free variables as keys
<antocuni> arigato: I admit that I don't fully understand the code
<rowillia> @LarstiQ so far I've been unable to create a repro not using rtree
<arigato> graingert: so in my current opinion, you are relying (on 2.7) on the fact that usually, if a dict has the same few keys, then d.keys() will return them in the same order
<arigato> independently on the order in which they were actually inserted into the dict
<arigato> this can fail though in case of hash collisions
<graingert> ah no not the same order as insertion
<graingert> two dicts with the same operations will return keys in the same order
<arigato> yes, but I'm saying something else
<arigato> if you stick a few string keys in an empty dictionary
<arigato> then d.keys() will often return the keys in an order that doesn't depend on the insertion order
<arigato> it's what the compiler does, so I think that's the reason for why co_freevars ends up in a consistent order
<arigato> here's an example where CPython 2.7.3 fails foul of this:
<arigato> CPython 2.7.13 fixed something, and now it works as expected as like CPython 3.x
<arigato> but they didn't add any test, so PyPy is still "broken" (both PyPy2 and PyPy3)
<arigato> indeed, Issue #15368 was backported to CPython 2.7.x too
<graingert> arigato: ah I see
<arigato> seems to be inside CPython 2.7.4 already
<graingert> arigato: always the same ordering for a single execution
<graingert> of Python
<graingert> with the same ops
<arigato> yes, as I said, that's not what I'm saying
<arigato> but never mind
rowillia has quit [Remote host closed the connection]
<antocuni> graingert: btw, "same ops ==> same dict" is not a valid assumption in general. It works with strings because they always hash the same, but if you take e.g. instances, then the hash depend on the id(), which is not deterministic
Guest13312 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
<graingert> antocuni: variable names are always strings
<graingert> antocuni: [(object(), object(), False)] != [(object(), object(), False)]
<graingert> antocuni: so not the same operations
<graingert> same ops ==> same dict stands
<antocuni> yeah I know, I just pointed out that it's not generally valid
tbodt has joined #pypy
<graingert> antocuni: but it is valid in general
<graingert> I don't understand your point
<graingert> when I do understand you, you're very helpful: I'm not trying to troll here
<graingert> antocuni: also 15368 only applies to different processes
<graingert> antocuni: ?
<antocuni> what?
<graingert> antocuni: you sent me a link to lugons
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tbodt has joined #pypy
tbodt has quit [Remote host closed the connection]
<graingert> but A(1) != A(1)
<antocuni> who cares. I simply pointed out that "same ops ==> same order of keys" is not generally valid
Guest13312 has joined #pypy
tbodt has joined #pypy
Guest13312 has quit [Client Quit]
<graingert> antocuni: for ops to be the same they either have to be:
<graingert> contain equal tuples all(a == b for a, b in zip(ops1, ops2))
<graingert> contain the same tuples all(id(a) == id(b) for a, b in zip(ops1, ops2))
<graingert> the same list by id(ops1) == id(ops2)
<graingert> although my assertion was only for id(ops1) == id(ops2)
jamesaxl has quit [Read error: Connection reset by peer]
<graingert> but I don't know why that would cause freevars to have a different order
<graingert> when they are all strings
jamesaxl has joined #pypy
<antocuni> sure, I'm not talking about freevars. I'm just saying that dictionary order is *generally* not deterministic
<antocuni> it is deterministic if you have a bunch of conditions, like the ones you wrote down (and which are not enough, I think)
<antocuni> but this is a weird definition of "general case"
<antocuni> that said, I don't really care
<antocuni> and it's dinner time :)
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tbodt has joined #pypy
<graingert> antocuni: no it's always deterministic, that's why hashdos is a thing
<antocuni> I don't know what to say, after having showed an example in which it's not
* antocuni off
jamesaxl has quit [Ping timeout: 260 seconds]
<graingert> antocuni: they had to make hashes intentionally non-deterministic with PYTHONHASHSEED. But that's only between runs
<graingert> but dictionaries are deterministic with regard to PYTHONHASHSEED
jamesaxl has joined #pypy
antocuni has quit [Ping timeout: 240 seconds]
Guest13312 has joined #pypy
<kenaan> arigo default 423026acc94c /pypy/: Fix co_freevars and co_cellvars to always list variables in alphabetical order. It seems that some bytecode hacks ...
<arigato> graingert: fixed
<arigato> thanks for the report
<graingert> arigato: on neato
Guest13312 has quit [Client Quit]
<graingert> arigato: can we get that in 2.7
<cfbolz> will be in the next release of both pypy2 and pypy3
<graingert> arigato: do you have a URL so I can send that to my co(_freevars)-conspirator
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<cfbolz> graingert: of course all these hacks are prone to breaking, and you really shouldn't complain if they do ;-)
<cfbolz> graingert: just saying that that list does not contain "may break on the next python minor version"
<graingert> cfbolz: could probably add that
<graingert> although isn't __code__ behavior part of the spec?
<cfbolz> no
<cfbolz> otherwise eg jython could never be compliant
<arigato> yes, it could: by exposing a __code__ that looks like CPython's, and never doing anything with it at all
<arigato> (just saying)
<cfbolz> sure, but that's somewhat pointless
<arigato> entirely, yes
<graingert> arigato: it would also have to read it
<pedronis> well it could do a two passes thing, just more work for the poor maintainers
<graingert> doesn't even try to support dis.dis
<graingert> just copies the CPython dis
<graingert> which doesn't work
<arigato> hi pedronis
<graingert> agates: well, when that hits pyenv I'll give it a go on travis
<pedronis> arigato: hi
Guest13312 has joined #pypy
<cfbolz> pedronis: heh, are you still reading stuff here, or do you have a highlight on jython?
<pedronis> no to the latter
<pedronis> I lurk I suppose :)
<cfbolz> ;-)
Guest13312 has quit [Client Quit]
<fijal> somehow strange semantics got pedronis out of lurking mode...
<fijal> graingert: I think in python 2.5 it was called func_code, not __code__ ;-)
jamesaxl has quit [Ping timeout: 240 seconds]
<graingert> fijal: still missing co_lnotab
<fijal> yeah that one would be silly on jython
<graingert> so they still have bytecode
<graingert> will have to try out 2.7
<cfbolz> no
<graingert> but they can't make a virtualenv
<cfbolz> graingert: jython compiles to java bytecode
<graingert> cjwelborn: that's not a problem
<graingert> I'm using the AST + compiler to make new bytecode
<graingert> so as long as it does the right thing with slots it should just work
<graingert> tm
<cfbolz> that's a dangerous "as long as"
vkirilichev has joined #pypy
<simpson> Yeah, I'd personally assume that the frame layout is *totally* different on each compilation.
* simpson smells Rice's Theorem
Guest13312 has joined #pypy
<dash> simpson: did you see the latest from our favorite crazy person? http://www.oilshell.org/blog/2017/04/09.html
Guest13312 has quit [Client Quit]
<kenaan> rlamy PyBuffer 3efce1d06791 /pypy/: Add .getbytes() and .setbytes() to Buffer to replace deleted getslice() and setslice()
<kenaan> rlamy PyBuffer 459611e8d6b4 /pypy/objspace/std/memoryobject.py: fix BufferSlice.w_getitem()
<kenaan> rlamy PyBuffer 4d42369e2fb3 /pypy/objspace/std/memoryobject.py: Fix tolist() on 1-D buffers
<simpson> dash: It's really seductive, isn't it? Python's so close to being self-hostable in a way that lets us hack the interpreter trivially and change the language radically.
<simpson> And yet.
<dash> simpson: If you only have to do it for a single python program, it's probably not too too much work.
<simpson> dash: I suppose that that would have worked if our single Python program were a specializeable Monte interpreter.
<simpson> Which we'd write in RPython since that's the only practical Python specializer. So I guess that we made the right choice.
<dash> simpson: that sounds very like what you're doing now...
<dash> heheh
oberstet has quit [Ping timeout: 252 seconds]
tbodt has joined #pypy
vkirilichev has quit [Remote host closed the connection]
<graingert> dash: why don't they just use HolyC
<dash> graingert: I daren't speculate.
vkirilichev has joined #pypy
<dash> (I just saw comments from Terry on a completely unrelated post. Spooky.)
kipras`away is now known as kipras
<graingert> ufora is a neato Python implimentation
<graingert> I'd like to see it be self hosted though
<graingert> they'd probably need Monads so they can read and write files though
vkirilichev has quit [Ping timeout: 260 seconds]
<dash> graingert: there's other stuff you can do
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tbodt has joined #pypy
<graingert> dash: oh sure
<graingert> dash: like with elm
<simpson> In an object-based languages, monads are a little clunky compared to object capabilities.
<simpson> TBH Ufora's quite restricted from what I can see. No safe eval() is a little unfortunate.
<graingert> def main(state: Optional[State], results = [Mapping[str, bytes]]) -> (State, Mapping[str, str]): pass
<graingert> you then return your state, and a Mapping of actions
<graingert> say URL and some data
<dash> graingert: sure, you could, but you could also just call some methods on some objects
<graingert> dash: you can't hand those to ufora
<dash> graingert: only because python is bad
<graingert> dash: unless they don't mutate
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
realitix has quit [Quit: Leaving]
tbodt has joined #pypy
linkmauve1 has quit [Ping timeout: 240 seconds]
tbodt has quit [Client Quit]
tbodt has joined #pypy
tbodt has quit [Client Quit]
tbodt has joined #pypy
jamesaxl has joined #pypy
arigato has quit [Quit: Leaving]
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jamesaxl has quit [Ping timeout: 240 seconds]
tbodt has joined #pypy
jamesaxl has joined #pypy
tbodt has quit [Client Quit]
tbodt has joined #pypy
tbodt has quit [Client Quit]
tbodt has joined #pypy
tbodt has quit [Client Quit]
jamesaxl has quit [Read error: Connection reset by peer]
Guest13312 has joined #pypy
<graingert> dash: how is python bad?
tbodt has joined #pypy
<dash> graingert: many answers are possible :) But the main criticism I have, in this context, is that it lacks encapsulation, so building secure environments like ufora wants is extremely hard and limited
<dash> graingert: it's fairly easy to imagine a python-like language where you can pass objects to untrusted code and be sure the untrusted code can't do anything unauthorized with them
<graingert> dash: I'd like Python to add more stuff so an immutable sunset makes sense
<graingert> dash: I'm not interested in permissions
<dash> ?
<graingert> dash: just immutable code
tbodt has quit [Client Quit]
<graingert> Subset
<graingert> Not sunset
<cfbolz> dash, graingert, simpson: all this is getting rather off topic to #pypy
<dash> cfbolz: sorry :)
<simpson> cfbolz: Sorry, I was just considering that blog post, which considers whether PyPy reuse would work for their project.
<graingert> Does pypy 3.5 support the comma placement rules of 3.6?
jamesaxl has joined #pypy
tbodt has joined #pypy
<graingert> Like it's got f expressions
tbodt has quit [Client Quit]
tbodt has joined #pypy
tbodt has quit [Client Quit]
<LarstiQ> comma placement rules?
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
<graingert> LarstiQ: you can put trailing commas everywhere
<graingert> Like def foo(*args, **kwargs,):
tbodt has joined #pypy
tbodt has quit [Client Quit]
tbodt has joined #pypy
tbodt has quit [Client Quit]
tbodt has joined #pypy
tbodt has quit [Client Quit]
<simpson> They finally fixed it!?
<dash> :O
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
oberstet has joined #pypy
Rhy0lite has quit [Quit: Leaving]
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
the_drow has quit [Ping timeout: 240 seconds]
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
jamesaxl has quit [Read error: Connection reset by peer]
tbodt has joined #pypy
<kenaan> tobweber stmgc[c8-long-transactions] 1b47d69c4988 /c8/stm/: Implement simple single thread mode that is activated if there are two or less segments in u...
<kenaan> tobweber stmgc[c8-long-transactions] f7c0d9ef8692 /c8/: Log single thread mode changes
<kenaan> tobweber stmgc[c8-long-transactions] 9fd6311549e1 /c8/stm/: Add debug output and minor refactorings
aboudreault has quit [Excess Flood]
aboudreault has joined #pypy
jamesaxl has joined #pypy
ramonvg has joined #pypy
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
yuyichao has quit [Ping timeout: 240 seconds]
squeaky_pl has joined #pypy
glyph_ is now known as glyph
jamesaxl has quit [Read error: Connection reset by peer]
Guest13312 has quit [Quit: http://www.kiwiirc.com/ - A hand crafted IRC client]
yuyichao has joined #pypy
jamesaxl has joined #pypy
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
jamesaxl has quit [Ping timeout: 240 seconds]
jamesaxl has joined #pypy
jacob22 has joined #pypy
jacob22_ has quit [Ping timeout: 240 seconds]
antocuni has joined #pypy
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
ramonvg has quit [Ping timeout: 255 seconds]
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
jamesaxl has quit [Ping timeout: 240 seconds]
jamesaxl has joined #pypy
jamesaxl has quit [Read error: Connection reset by peer]
<graingert> simpson: dash yeah it's great
<graingert> simpson: dash: "To be explicit, yes, I want to allow trailing comma even after *args or **kwds. And that's what the patch does."
jamesaxl has joined #pypy
<graingert> I think it should be added to pypy 3.5 for the same reasons f strings are
nimaje is now known as Guest32775
nimaje1 has joined #pypy
Guest32775 has quit [Killed (hobana.freenode.net (Nickname regained by services))]
<cfbolz> graingert: patches welcome
jamesaxl has quit [Ping timeout: 252 seconds]
<graingert> cfbolz: don't fancy starting on it unless it's a feature that's desired
<cfbolz> Well, eventually we will have to write 3.6 support
jamesaxl has joined #pypy
<graingert> cfbolz: sure
<graingert> cfbolz: but I don't fancy it languishing on a 3.6 branch
vkirilichev has joined #pypy
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #pypy
tbodt has joined #pypy
squeaky_pl has quit [Ping timeout: 255 seconds]
yuyichao has quit [Ping timeout: 240 seconds]
yuyichao has joined #pypy
jamesaxl has quit [Read error: Connection reset by peer]
<cfbolz> graingert: there is no 3.6 branch yet. It would just go to 3.5 imo
jamesaxl has joined #pypy
<graingert> cfbolz: ah neato
jamesaxl has quit [Ping timeout: 255 seconds]
jamesaxl has joined #pypy
jamesaxl has quit [Client Quit]
tbodt has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<graingert> cfbolz: bbot2_ is a bit spammy
tbodt has joined #pypy
<cfbolz> graingert: it's giving the developers useful info
<graingert> cfbolz: looks like a lot of redundancy
tbodt has quit [Read error: Connection reset by peer]
tbodt has joined #pypy
adamholmberg has quit [Remote host closed the connection]
adamholmberg has joined #pypy
adamholmberg has quit [Ping timeout: 240 seconds]
tbodt has quit [Read error: Connection reset by peer]
<simpson> graingert: Glad to see it finally fixed: https://twitter.com/corbinsimpson/status/313679862495866880
tbodt has joined #pypy
vkirilichev has quit [Remote host closed the connection]
vkirilichev has joined #pypy
antocuni has quit [Ping timeout: 255 seconds]
vkirilichev has quit [Ping timeout: 240 seconds]
kipras is now known as kipras`away
tbodt has quit [Remote host closed the connection]
tbodt has joined #pypy