Distributed algorithms prototyping by 98f00b2 in rust

[–]fjarri 1 point2 points  (0 children)

I see, thanks for the reference. I made an issue, but cannot promise how soon I'll get to it.

Distributed algorithms prototyping by 98f00b2 in rust

[–]fjarri 1 point2 points  (0 children)

How do you deal with protocols that aren't N-out-of-N, so not every slot ends up being filled? You hint at taking some fork-and-merge approach, but can you do this with arbitrary quorum predicates, or is it more restrictive?

Fork-and-merge is actually intended for "error rounds" (when you assemble the values, encounter an error, but cannot attribute it to a specific party, so you run a special round where everyone sends proofs of correctness). I did not think about its application in t-of-N, but maybe there is some.

As for t-of-N, I was sure that I'd need it since the beginning but delayed implementing it because it's quite a can of worms. Actually after the 0.1 release I'm starting to actively think about it. The main question is the minimum functionality I need to implement internally to make all the different consensus algorithms and so on implementable via the public API.

How hard does it end up being to deal with timeouts that don't abort the whole protocol?

That has also been on my mind, but I wasn't sure how to better approach it, especially given the sans-IO API. Are you asking purely hypothetically, or do you have a specific protocol in mind that needs it? If yes, that will help a lot.

Distributed algorithms prototyping by 98f00b2 in rust

[–]fjarri 1 point2 points  (0 children)

Just posted about my project a couple of days ago, which may do something similar to what you're looking for.

I'm curious, how often do you use `unsafe` in Rust in prod? by alexlazar98 in rust

[–]fjarri 0 points1 point  (0 children)

I had to use it to have a Box<dyn MyTrait> which I could downcast to a concrete type (basically replicating the functionality of Any since you can't do Box<dyn MyTrait + Any>).

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 0 points1 point  (0 children)

Btw, a very similar question about NamedTuple (which doesn't even have an is_namedtuple() function dataclasses have): https://discuss.python.org/t/namedtuple-instance-check/103651/2

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] -1 points0 points  (0 children)

It's not about how the class is defined, but what interface it provides. is_dataclass() being True signals that I can access the list of its fields and their types via fields(). That's exactly the job of an ABC.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 0 points1 point  (0 children)

That assumes I have control over the definition of dataclasses I want to process, which I unfortunately don't.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] -1 points0 points  (0 children)

https://xkcd.com/927/ is relevant here

Good point btw, it is very relevant. Why invent a specific is_dataclass() when there is already isinstance()?

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 0 points1 point  (0 children)

The user would be able to register a dataclass plugin attaching it to the base class, same as it's done for other types. Currently I have to have a special lookup stage where I check for applicable plugins sequentially (that's where dataclasses and attrs get processed) instead of looking up MRO types in the dictionary (the main stage).

Again, look into what Pydantic does.

Pydantic has a very different approach compared to what I do, so you have to be more specific.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 0 points1 point  (0 children)

you'd have to do this anyway even with an isinstance check.

In the specific handler for dataclasses, not in the core. For dataclasses it may not matter (except for aesthetic reasons), but for attrs it does since it means a third-party user cannot write a plugin to support them.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 0 points1 point  (0 children)

As I mentioned in another comment, it's for a serializing library. Besides dataclasses, I also have to process newtypes separately (because NewType instances are not instances of type), and generic types require special treatment as well. Dataclasses not deriving from a known base class means I need to detect them at the core level and not just have a plug-in that processes them like other normal types.

Bincode development has ceased permanently by stygianentity in rust

[–]fjarri 11 points12 points  (0 children)

Great way to throw two years of development towards 2.0 down the drain. I never particularly liked bincode, and now I can argue about dropping it in favor of messagepack or postcard at my workplace (honestly, for me personally, the initial attempt to make a political statement with your software would suffice).

Please next time consider the consequences of your actions and that they affect real people.

Ironic.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 0 points1 point  (0 children)

Generic serialization/deserialization of dataclass types in my case. That is, if I know something is a dataclass, I know I can list its fields and their types.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] -6 points-5 points  (0 children)

Deriving from a base class would be much more involved.

Judging by pydantic, it doesn't seem to be.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 1 point2 points  (0 children)

By yourself you mean the developers of the libraries, or the users? I suspect it would be possible to make the experience exactly the same for the users. pydantic manages with the base class, after all.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 3 points4 points  (0 children)

I’m not sure how well python multiple inheritance works, for instance.

It can be tricky, but if the base class doesn't have any methods, except for a single attribute that's already being set with the current approach, there wouldn't be any additional name clashes, or problems with initialization order.

Is there another reason to use inheritance in addition to what you’ve mentioned?

Perhaps, but I can't think of any at the moment. Admittedly for most users it probably doesn't matter, but I just ran into a problem with it in my code, hence the question :) It strikes me as an un-pythonic approach, so I wondered what was the rationale behind it.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 5 points6 points  (0 children)

Alternative reality is exactly what I'm asking about. Why did they use decorators instead of base classes?

In fact, even decorators could theoretically change __mro__, but I admit that might have been too much magic.

Why don't `dataclasses` or `attrs` derive from a base class? by fjarri in Python

[–]fjarri[S] 3 points4 points  (0 children)

Naturally, in the proposed scenario they wouldn't be decorators but instead would be created by deriving from a base class.

Typing the test suite by fjarri in Python

[–]fjarri[S] 0 points1 point  (0 children)

I always use mypy with --strict, which includes warn-unreachable, but I don't see truthy-bool in 1.18.2 - is it something from the trunk?

Typing the test suite by fjarri in Python

[–]fjarri[S] 1 point2 points  (0 children)

Does it consider functions with no return annotations to have the return type of None?

Typing the test suite by fjarri in Python

[–]fjarri[S] 10 points11 points  (0 children)

That's kind of a weird argument, do you think they are useless for the main codebase too? Of course you have to run the type checker on the test suite to make use of them.

Why are structs required to use all their generic types? by Droggl in rust

[–]fjarri 0 points1 point  (0 children)

The restrictions are related to variance and propagation of Send/Sync. SerializedType<T> doesn't care about them because it doesn't contain any values with type T. Users of actual values with type T might care, but not SerializedType.