lkcl | vaino[m], nice to have you around, sorry we had some "interesting" news that needed fast evaluation, normally the coffee meetings are much more free-form if you know what i mean | 01:20 |
---|---|---|
lkcl | ghostmansd[m], ohh like "are the bit-fields of these operands overlapping"? that sort of thing | 01:21 |
lkcl | my biggest concern about visitor-walking is that the act of "visiting" (the actual tree-walking) be *entirely* separated from "the action(s) taken" | 01:23 |
lkcl | that's extremely important, and is something that the python-html-visitor gets right | 01:24 |
lkcl | and if the *entire* database is constructed in terms of "lists of fields" and "child-lists" - just like in the python *2.7* ast.py - then it is a matter of implementing one function to do that: do_a_visit_walk() | 01:26 |
lkcl | look-up by classname is neat. | 01:27 |
lkcl | i can't quite "consciously" guess what you mean about __getattr__ but subconsciously i know you will have a really good idea there :) | 01:28 |
lkcl | sadoon[m]1, tyan server... tyan server... oh - the MIPS64-based Loongson ones? awesome! | 01:29 |
lkcl | ghostmansd[m], the solution to "how do i do a filter" is: | 01:29 |
lkcl | class VisitFilterByRecord: | 01:30 |
lkcl | def __init__(self, filterfn): self.filterfn = filterfn | 01:30 |
lkcl | def visit_child_Record(self, node): | 01:31 |
lkcl | if self.filterfn(node): self.__current_record = node | 01:32 |
lkcl | def visit_child_Record_after(self, node): | 01:32 |
lkcl | self.__current_record = None | 01:32 |
lkcl | def visit_child_Record_field(self, node): | 01:32 |
lkcl | if self.__current_record is None: return | 01:33 |
lkcl | .... | 01:33 |
lkcl | .... | 01:33 |
lkcl | in other words the Visitor has *no control* over how deep the walking goes, the do_visitor_walk() function *will* go in a fixed-order over the entire database, down every single field in a strict breadth-first tree-walk | 01:35 |
lkcl | and the nice thing about having the 3-functions is: | 01:35 |
lkcl | you can have the visitor-instance do Polish Notation (op A B), Reverse-polish Notation (A B op) or standard notation (A op B) depending on whether you use the pre-child, child, or post-child function to push/pop stuff off of a stack | 01:37 |
lkcl | (where the stack is, you guessed it, a local class-member-variable of the Visitor-instance, *not* a fixed type-defined base-class member of a pre-defined suite of visitors) | 01:39 |
lkcl | oh btw do look up "__call__()" | 01:45 |
lkcl | *extremely* useful | 01:45 |
lkcl | what duh... :) https://github.com/realistschuckle/pyvisitor/blob/master/src/visitor.py | 01:45 |
lkcl | nice.. except argh argh the "accept" function is performing the exact explicit-control i don't think should be exposed into the visitor itself | 01:50 |
lkcl | ("controlling" the depth) | 01:50 |
lkcl | https://github.com/realistschuckle/pyvisitor/tree/master/example | 01:50 |
*** ghostmansd <ghostmansd!~ghostmans@91.205.168.237> has joined #libre-soc | 08:12 | |
*** ghostmansd <ghostmansd!~ghostmans@91.205.168.237> has quit IRC | 08:17 | |
*** ghostmansd <ghostmansd!~ghostmans@91.205.168.237> has joined #libre-soc | 08:18 | |
*** ghostmansd[hexch <ghostmansd[hexch!~ghostmans@91.205.168.237> has joined #libre-soc | 08:39 | |
*** ghostmansd <ghostmansd!~ghostmans@91.205.168.237> has quit IRC | 08:41 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 08:52 | |
*** ghostmansd[hexch <ghostmansd[hexch!~ghostmans@91.205.168.237> has quit IRC | 08:55 | |
*** markos_ <markos_!~markos_@user/markos/x-1838887> has quit IRC | 09:20 | |
*** markos_ <markos_!~markos_@62.74.12.149> has joined #libre-soc | 09:33 | |
*** markos_ <markos_!~markos_@user/markos/x-1838887> has joined #libre-soc | 09:33 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 09:40 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 09:40 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 09:50 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 09:51 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 10:04 | |
vaino[m] | lkcl, no problem, it was good to sort of see what's currently going on | 10:05 |
lkcl | toshywoshy, ping, openpowerbot gone walkies on libera? | 10:26 |
lkcl | programmerjake, openpowerbot's gone walkies and i know you had a diff that you identified where rldimi wasn't happy? can you put it into https://bugs.libre-soc.org/show_bug.cgi?id=1115 | 10:27 |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 10:31 | |
*** markos_ <markos_!~markos_@user/markos/x-1838887> has quit IRC | 10:38 | |
*** openpowerbot <openpowerbot!~openpower@94-226-187-44.access.telenet.be> has joined #libre-soc | 10:45 | |
ghostmansd[m] | lkcl, I posted some updates on visitors in 1094, please take a look when you have some free time | 10:54 |
*** markos_ <markos_!~markos_@static062038151250.dsl.hol.gr> has joined #libre-soc | 11:01 | |
*** markos_ <markos_!~markos_@user/markos/x-1838887> has joined #libre-soc | 11:01 | |
lkcl | ghostmansd[m], ack. | 11:11 |
lkcl | i finally found something that explains: https://medium.com/design-patterns-in-python/visitor-pattern-b9227759d6be | 11:13 |
lkcl | the separation between "Visitor" and "Visiting" is *real* important | 11:14 |
lkcl | the irony is that this is a ridiculously-small amount of code. | 11:15 |
lkcl | ghostmansd[m], "Visitable" is still merged with "Visitor". Visitors should not have "for opcode in node.opcodes:" | 11:38 |
lkcl | the *Visitable* should have "for opcode in node.opcodes:" and that should be *in Record*, *in Database*, *in SVP64Instruction* | 11:39 |
lkcl | and one of the arguments to it: the visitor. | 11:39 |
ghostmansd[m] | The link doesn't open | 11:40 |
lkcl | wrong: class SVP64InstructionVisitor(InstructionVisitor): pass | 11:40 |
lkcl | right: class SVP64InstructionVisitor(IVisitable): | 11:40 |
lkcl | i found the original | 11:40 |
ghostmansd[m] | What's merged? I don't get it. | 11:40 |
lkcl | https://sbcode.net/python/visitor/#visitorvisitor_conceptpy | 11:41 |
lkcl | the concept of "Visitable" with the concept of "Visitor" | 11:41 |
ghostmansd[m] | You have Node and the way to visit it | 11:41 |
lkcl | Visitors should - must - *not* do "walking of child objects" themselves | 11:41 |
lkcl | if there is a for-loop on child objects *inside* the Visitor, this is the wrong approach | 11:42 |
lkcl | i'll edit the bugreport comments because that medium.com link requires "membership", i didn't realise | 11:43 |
ghostmansd[m] | So your point is that inside the specific handler we should not manually invoke a loop which iterates? | 11:43 |
ghostmansd[m] | If so, this can be done. | 11:43 |
ghostmansd[m] | But this is kinda too restricting, because this is the best way to skip certain exact records. | 11:44 |
lkcl | correct | 11:44 |
lkcl | the "normal" approach to skipping (filtering) is to have the Visitor keep track (by creating local variables self.__current_record for example) | 11:46 |
lkcl | hmm hmm i am thinking... | 11:48 |
lkcl | i'd really like to see the entire walking (the nested for-loops) be driven by reading self._fields | 11:49 |
lkcl | and... ahhh... then filtering can be done as an *intermediate* stage. | 11:51 |
lkcl | toshywoshy, thx openpowerbot is back | 11:51 |
ghostmansd[m] | Hard no on reading a private member field. | 11:55 |
ghostmansd[m] | Good with explicit property. | 11:55 |
ghostmansd[m] | And it's already done, it's just that filtering still happens inside the handler. And I don't see how introducing a context makes it better. | 11:56 |
ghostmansd[m] | But even if I don't see its benefits, I still can do it. | 11:56 |
*** ghostmansd[hexch <ghostmansd[hexch!~ghostmans@91.205.168.237> has joined #libre-soc | 12:01 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 12:04 | |
lkcl | *private* member field? no this is public member fields | 12:04 |
lkcl | all fields are public. Record.dynamic_operands is public, Record.static_operands is public, yes? | 12:05 |
lkcl | ok, i think i can illustrate: | 12:05 |
lkcl | how with *one function* down at the base class as a staticmember function can you printout the *entire* database structure? | 12:06 |
lkcl | not the contents | 12:07 |
lkcl | just the structure | 12:07 |
lkcl | (it should be possible if every single object used in the entire system has a "fields" member. | 12:08 |
lkcl | much as i don't like dataclasses, there is a way to do exactly this | 12:08 |
lkcl | here: | 12:10 |
lkcl | https://docs.python.org/3/library/dataclasses.html#dataclasses.fields | 12:10 |
lkcl | > But even if I don't see its benefits, I still can do it | 12:14 |
lkcl | i'd very much like you to understand why, rather than "just do it" if you know what i mean | 12:14 |
lkcl | presently the "picture in my head" is {walker/Visitable}<-{filter_function} -> {Visitor} | 12:16 |
lkcl | basically separating what is currently *all three* roles in one! | 12:17 |
lkcl | def Record(self, node, depth): | 12:18 |
lkcl | for operand in node.dynamic_operands: | 12:18 |
lkcl | this is not a visitor pattern | 12:18 |
lkcl | if operand.name not in ("PO", "XO"): | 12:19 |
lkcl | that is the filter | 12:19 |
lkcl | desc = f"{operand.name}={operand.value}" | 12:19 |
lkcl | print(desc, ",".join(map(str, operand.span))) | 12:19 |
lkcl | *that* is the Visitor! | 12:19 |
lkcl | sorry | 12:19 |
lkcl | let me do that again | 12:19 |
lkcl | def Record(self, node, depth): | 12:19 |
lkcl | for operand in node.dynamic_operands: | 12:19 |
lkcl | this is the *Visitable* pattern | 12:19 |
lkcl | if operand.name not in ("PO", "XO"): | 12:20 |
lkcl | that is the filter | 12:20 |
lkcl | desc = f"{operand.name}={operand.value}" | 12:20 |
lkcl | print(desc, ",".join(map(str, operand.span))) | 12:20 |
lkcl | *that* is the Visitor! | 12:20 |
lkcl | all three should be completely separated | 12:20 |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 12:39 | |
*** ghostmansd[hexch <ghostmansd[hexch!~ghostmans@91.205.168.237> has quit IRC | 12:42 | |
lkcl | ghostmansd[m], i'm slowly beginning to grasp this. it's difficult to give examples because there are *so many* people who have done "visitor" patterns that aren't actually properly separated. | 12:47 |
lkcl | one of the downsides of python becoming popular :) | 12:47 |
lkcl | guido van rossum was really damn good at this stuff | 12:47 |
lkcl | he developed python as a teaching-tool as part of working as a university lecturer | 12:48 |
lkcl | whilst doing his PhD (i think) | 12:48 |
sadoon[m]1 | Slightly bad news: my manager retired and the new one absolutely despises me for.. Many reasons lmao | 14:14 |
sadoon[m]1 | So I'm still going to be busy as I look into my options, most likely finding another job | 14:14 |
sadoon[m]1 | Wish me luck | 14:14 |
vaino[m] | good luck sadoon, that sounds tough. I hope you find a better place | 14:18 |
markos_ | sadoon[m], what are you looking for? maybe we can help here | 14:21 |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 14:25 | |
sadoon[m]1 | Thanks everyone | 14:35 |
sadoon[m]1 | Looking for a local job offer, nothing international. Preferably in teaching | 14:35 |
sadoon[m]1 | There's a lab engineer position open for electronics and electrical engineering, just what I need | 14:36 |
sadoon[m]1 | Closes soon so I need to be very swift about it | 14:37 |
markos_ | well good luck | 14:38 |
sadoon[m]1 | Thanks | 14:44 |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 15:00 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 15:19 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 15:21 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 15:25 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 15:25 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 15:30 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 15:30 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 15:38 | |
*** yambo <yambo!~yambo@069-145-110-003.biz.spectrum.com> has quit IRC | 16:34 | |
*** yambo <yambo!~yambo@069-145-110-003.biz.spectrum.com> has joined #libre-soc | 16:46 | |
*** lxo <lxo!~lxo@gateway/tor-sasl/lxo> has quit IRC | 16:50 | |
*** lxo <lxo!~lxo@gateway/tor-sasl/lxo> has joined #libre-soc | 16:50 | |
*** markos_ <markos_!~markos_@user/markos/x-1838887> has quit IRC | 18:35 | |
ghostmansd[m] | lkcl, what's now wrong with matcher? | 18:37 |
ghostmansd[m] | That's exactly the same stuff you suggested except that you can have per-type matcher. | 18:38 |
ghostmansd[m] | It's a callable which gets a node and returns bool. | 18:39 |
ghostmansd[m] | What exactly "increases" the code in size? Please check base classes. You probably look into concrete visitors with their prints. | 18:40 |
ghostmansd[m] | As for depth, this comes from AST. I have no problems if the code around bookkeeps it, but it's handy. | 18:41 |
ghostmansd[m] | Walking _IS_ separate from action. All the walk is done in classes. | 18:42 |
ghostmansd[m] | Actions are in visitor. | 18:42 |
ghostmansd[m] | It's only that the action might be "don't match this node as a candidate for calling the action". | 18:43 |
ghostmansd[m] | Unless you restrict the matching, this is a walk-over-anything-this-has. | 18:44 |
ghostmansd[m] | No I don't want "isinstance" check with some list instead of inheritance. First, I want to be able to decide what's walked in the corresponding classes, because some of this information is too low-level or too ungrouped (cf. extras). Second, isinstance is probably the most shitty way to do it. It breaks the duck type. | 18:47 |
*** markos_ <markos_!~markos_@static062038151250.dsl.hol.gr> has joined #libre-soc | 18:48 | |
*** markos_ <markos_!~markos_@user/markos/x-1838887> has joined #libre-soc | 18:48 | |
ghostmansd[m] | In the example you posted with AST, it's the same except that the user might skip some nodes. Yes I do think it's perfectly correct and valid, and in no ways is different to "accept_filter" except that it allows to avoid isinstance checks in accept_filter. | 18:52 |
ghostmansd[m] | The isinstance check is just implemented in the way like it's done with handler (to the degree they actually do the same thing: invoke per-class __call__ or call a stub). | 18:53 |
ghostmansd[m] | Treat it as "accept_filter which is callable in a per-class way". | 18:55 |
ghostmansd[m] | As for using dataclasses.fields, yes this might be the option. I find some information too low-level, but this can be done. However, I want to have higher-level information. You can, for example, what `def extras` returns, and which fields reside in fact. This can be done, but it needs refactoring so that the high-level fields are constructed upon initialization. I don't have time for this yet. | 19:04 |
programmerjake | > programmerjake, openpowerbot's gone walkies and i know you had a diff that you identified where rldimi wasn't happy? | 19:27 |
programmerjake | iirc ghostmansd is the one who found it, not me | 19:27 |
programmerjake | i don't actually have a diff | 19:27 |
programmerjake | lkcl ^ | 19:28 |
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.166.58> has quit IRC | 19:28 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 19:34 | |
ghostmansd[pc] | lkcl, I think I finally understood what you meant | 19:38 |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 19:38 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has joined #libre-soc | 19:38 | |
ghostmansd[pc] | lkcl, I think I finally understood what you meant | 19:39 |
*** markos_ <markos_!~markos_@user/markos/x-1838887> has quit IRC | 19:40 | |
ghostmansd[pc] | Is the whole problem that you don't want visitors to be passed to Whatever.visit() and you want to have Whatever.subnodes instead? | 19:41 |
ghostmansd[pc] | (I'd have used Whatever.__iter__, but it's used for other internal purposes sometimes in insndb's classes). | 19:42 |
*** markos_ <markos_!~markos_@static062038151250.dsl.hol.gr> has joined #libre-soc | 19:51 | |
*** markos_ <markos_!~markos_@user/markos/x-1838887> has joined #libre-soc | 19:51 | |
ghostmansd[pc] | I'm changing this part. That said, I like the matcher concept, I'm keeping it. I don't want any of this "if isinstance" crap, at all. This will be used just in insndb.Whatever.subnodes call so that I can pass it to insndb.walk as an optional argument. | 19:57 |
ghostmansd[pc] | Hm. Perhaps matchers won't be of no use at all. Still checking. | 20:33 |
*** octavius <octavius!~octavius@92.40.168.213.threembb.co.uk> has joined #libre-soc | 20:56 | |
ghostmansd[pc] | lkcl, ignore the stuff atop, check just https://bugs.libre-soc.org/show_bug.cgi?id=1094#c60 | 21:02 |
*** libredev <libredev!libredev@ircforever.org> has quit IRC | 21:05 | |
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@91.205.168.237> has quit IRC | 21:09 | |
*** octavius <octavius!~octavius@92.40.168.213.threembb.co.uk> has quit IRC | 21:29 | |
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@176.59.52.1> has joined #libre-soc | 21:32 | |
*** libredev <libredev!libredev@libredev.ircforever.org> has joined #libre-soc | 22:33 |
Generated by irclog2html.py 2.17.1 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!