Has anyone tried to integrate Go with Python? Right now, optimizing Python code by replacing critical sections with C works really well and isn't too hard to write or distribute. How well would tooling around doing the same thing with Go work?
That won't help you much with concurrency problems, however "multiprocessing" does.
What Python developers need to know before migrating to Go
21–30 of 117 posts
Re: What Python developers need to know before migrating to Go
#22Earlier quoted context omitted.
That won't help you much with concurrency problems, however "multiprocessing" does.
Well, it could, if your use case gets down to "pass an entire work unit in, get a result back".
Re: What Python developers need to know before migrating to Go
#23Writing to a file, there’s File.Write([]byte) and File.WriteString(string) – a bit of a departure for Python developers who are used to the Python zen of having one way to do something
Simply because it's not currently feasible to write a function that can have multiple type signatures (via overloading, generics, etc.).
Going between []byte and string. regexp uses []byte (they’re mutable). It makes sense, but it’s annoying all the same having to cast & re-cast some variables.
There are actually two different versions of each regexp function: one for strings, one for []byte. Maybe they're using a different version?
No tuples, have to write your own structs or use slices (arrays)
Actually, you can declare a fixed-length array as a type. So if you need to return a triple of ints, you can declare the return type to be [3]int and have the type system check that you're actually returning an array of ints of length 3.
Similarly, a lot of the other bullet points are natural results of having a static type system.
I was expecting more points like:
* you can't monkey-patch functions into external libraries like you can with Python modules * no generics, so you can't write a generic "map" function, for example * no preemptive multitasking, so one goroutine can wedge the entire program * passing around arrays and structs is by value, leading to unexpected allocation and memory usage * pointers
Re: What Python developers need to know before migrating to Go
#24Has anyone tried to integrate Go with Python? Right now, optimizing Python code by replacing critical sections with C works really well and isn't too hard to write or distribute. How well would tooling around doing the same thing with Go work?
Re: What Python developers need to know before migrating to Go
#25>> No built-in type for sets (have to use maps and test for existence) Is there any particular reason for this? Sets are so fundamental to mathematics and beyond that I am concerned right away about this. Sure you could use a map as a replacement, but what happens to "user experience"? I do not get this for other languages as well. Data structures that are present in nearly all computer science books are often not bu…
Re: What Python developers need to know before migrating to Go
#26>> No built-in type for sets (have to use maps and test for existence) Is there any particular reason for this? Sets are so fundamental to mathematics and beyond that I am concerned right away about this. Sure you could use a map as a replacement, but what happens to "user experience"? I do not get this for other languages as well. Data structures that are present in nearly all computer science books are often not bu…
In Java, sets are merely wrappers around a map that maps to a dummy. I guess Go just left off the wrapper.
Re: What Python developers need to know before migrating to Go
#27Is there a decent numpy/scipy equivalent for Go yet? By which I mean an easy way to manipulate matrices, complex numbers perform discrete Fourier transforms and the like.
Re: What Python developers need to know before migrating to Go
#28Any HN readers of this post have any similar experience? I know the bright team over at bit.ly made a successful switch from python to go-- anyone else? The more I hear about go, the more I like it.
Re: What Python developers need to know before migrating to Go
#29In my mind, a map is a set. They are both Associative containers. It's just that the key and value can be different things in a map while in a set, the key and value are the same thing.
Edit: I speak from a strong C++ viewpoint, but maybe Go is not like that (I'm not sure why it would not be): https://en.wikipedia.org/wiki/Associative_containers_%28C%2B...
Re: What Python developers need to know before migrating to Go
#30Some of the things they listed are dubious... Writing to a file, there’s File.Write([]byte) and File.WriteString(string) – a bit of a departure for Python developers who are used to the Python zen of having one way to do something Simply because it's not currently feasible to write a function that can have multiple type signatures (via overloading, generics, etc.). Going between []byte and string. regexp uses []byte…
That's different from a tuple as it is commonly known in Python and statically typed languages. Tuples can be heterogeneous in languages like Python, OCaml, and Haskell, which Go fixed length arrays can't be. For example, in Go you can't have `(int, float)`.