Re: [go-nuts] Any interest in nat.mulRange simplification/optimization?

2024-01-13 Thread Bakul Shah
Fair enough! I replied as I found a factor of 60 a bit surprising. Though I shouldn't have been -- my n digits of pi scheme program was consistently about 16-17 times slower than gmp based one (at least up to 1E9), using the same algorithm (Chudnovsky's), which is also highly dependent on multi

Re: [go-nuts] Any interest in nat.mulRange simplification/optimization?

2024-01-13 Thread Rob Pike
This is getting interesting but maybe only for me, so I'll stop here. I did some profiling and the majority of the time is spent in math/big.addMulVVW. Thinking I might be doing something stupid, I compared it with the Go implementation at http://www.luschny.de/math/factorial/scala/FactorialScalaC

Re: [go-nuts] Any interest in nat.mulRange simplification/optimization?

2024-01-13 Thread Rob Pike
Oh, I did say my implementation was straightforward. It's free of any clever multiplication algorithms or mathematical delights. It could easily be giving up 10x or more for that reason alone. And I haven't even profiled it yet. -rob On Sat, Jan 13, 2024 at 7:04 PM Bakul Shah wrote: > FYI Juli

Re: [go-nuts] New type in generics

2024-01-13 Thread Daniel Theophanes
Thank you. Yeah, that seems overly complicated. I can allocate interior to the generic object, but I can't use pointer-receiver methods, which is fine in my case, I'll just adjust the interior manually. Thank you. On Saturday, January 13, 2024 at 1:50:17 PM UTC-6 Axel Wagner wrote: > The way to

Re: [go-nuts] New type in generics

2024-01-13 Thread 'Axel Wagner' via golang-nuts
The way to do that is to add another level of indirection (as everything in Software Engineering): type Namer[T any] interface { *T SetName(name string) } func WithName[T any, PT Namer[T]](name string) T { var v T PT(&v).SetName(name) return v } I will say, though, that it's n

[go-nuts] New type in generics

2024-01-13 Thread Daniel Theophanes
I have a situation where I would like to create a type, then set a property on it within a container. To set the type, I envisioned using a method "SetName" which would need to take a pointer receiver: (goplay share is down right now so I'll post inline: type Namer interface { SetName(name strin

[go-nuts] [NOTE] GOPL Type Theory

2024-01-13 Thread John Pritchard
Hi, It occurs to me that GOPL type theory has a distinct benefit from its constraint to the membership relation. The external derivation of type semantics has particular constraint. Tools parsing GOPL expressions and systems are more readily capable of reproducing type semantics. The benefit of

Re: [go-nuts] Any interest in nat.mulRange simplification/optimization?

2024-01-13 Thread Bakul Shah
FYI Julia (on M1 MBP) seems much faster: julia> @which factorial(big(1)) factorial(x::BigInt) in Base.GMP at gmp.jl:645 julia> @time begin; factorial(big(1)); 1; end 27.849116 seconds (1.39 M allocations: 11.963 GiB, 0.22% gc time) Probably they use Schönhage-Strassen multiplica