[go-nuts] Re: Go is two times slower than python code?

2016-11-30 Thread Thomas Modeneis
+6 years later, It seems that this issue still a problem.
There is a open ticket on github for 
it: https://github.com/golang/go/issues/16791

I've been facing this issue for a while, and on my experience the best 
workaround is to serialize the CSV to the disk after reading it.

Cheers.

On Tuesday, March 9, 2010 at 3:52:16 PM UTC+1, Alex Dong wrote:
>
> I'm writing a simple 'word picker' using golang and python. It
> basically reads a tweeter message from a csv file, tokenize it and put
> the word->id into a map called lexicon.  It turned out that same logic
> took 22 seconds for python 2.6 to finish whereas 57 seconds for
> golang!
>
> Wondering are there anything I've done wrong?
>
> Here is the python code:
> $ cat loader.py
> lexicon = {}
> pnct_ptn = re.compile(r'([\.,\\/\'"\?!=_\)\(\]\[\{\}:;]+|http://[^ ]
> +)')
> def tokenize(s):
> s = pnct_ptn.sub(' ', s)
> return [t for t in s.split() if len(t)>=3]
>
> for line in open("result.csv").readlines():
> parts = line.split(',', 3)
> if len(parts) != 4: continue
> msg = parts[3]
> s  = msg.decode('utf8','ignore').lower()
> for word in tokenize(s):
> if not lexicon.has_key(word):
> unique_words += 1
> lexicon[word] = unique_words
>
> Here is the go code:
> $ cat loader.go
> package main
>
> import (
> "bufio"
> "os"
> "regexp"
> "strings"
> )
>
> var (
> pr, _ = regexp.Compile(`(http://[^ ]+|['".\\,=()*:;?!/]|-)`)//
> pattern for removal
> )
>
> func tokenize(s string) []string {
> ms := pr.ReplaceAllString(strings.ToLower(s), " ")
> return strings.Split(ms, " ", 0)
> }
>
> func main() {
> lex := make(map[string] int)// lexicon
> dic := make(map[int] string)// lookup
> tw  := 0// total
> words
> ps  := false// present
>
> r, _ := os.Open("result.csv", os.O_RDONLY, 0444)
> defer r.Close()
> in := bufio.NewReader(r)
>
> for i := 0; i >= 0; i++ {
> line, err := in.ReadString('\n')
> if err != nil {
> break
> }
>
> parts:= strings.Split(line, ",", 4)
> if len(parts) != 4 {
> continue
> }
>
> ts := tokenize(parts[3])
> for d := 0; d < len(ts); d++ {
> w := ts[d]
> if len(w) < 3 {
> continue
> }
> _, ps = lex[w]
> if ps == false {
> lex[w] = tw
> dic[tw] = w
> tw ++
> }
> }
> }
> }
>
>
> Cheers,
> Alex
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: go get: You are not currently on a branch

2016-10-25 Thread Thomas Modeneis
gurp...@gmail.com wrote:
"The error occurs because the repo got a new branch since your last go 
get." 

...right ... but look how many errors, one have to manually get "fixed" in 
order get a dependency updated.

$ go get -u github.com/dancannon/gorethink
# cd /opt/gocode/src/github.com/Sirupsen/logrus; git pull --ff-only
>From https://github.com/Sirupsen/logrus
   08a8a7c..3ec0642  master -> origin/master
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

git pull  

package github.com/Sirupsen/logrus: exit status 1
# cd /opt/gocode/src/github.com/cenk/backoff; git pull --ff-only
>From https://github.com/cenk/backoff
   cdf48bb..b02f2bb  master -> origin/master
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

git pull  

package github.com/cenk/backoff: exit status 1
# cd /opt/gocode/src/github.com/hailocab/go-hostpool; git pull --ff-only
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

git pull  

package github.com/hailocab/go-hostpool: exit status 1
# cd /opt/gocode/src/gopkg.in/dancannon/gorethink.v2; git pull --ff-only
>From https://gopkg.in/dancannon/gorethink.v2
   e75f34b..016a1d3  master -> origin/master
   b2c14ad..016a1d3  develop-> origin/develop
 * [new tag] v2.2.2 -> v2.2.2
>From https://gopkg.in/dancannon/gorethink.v2
 * [new tag] v2.2.1 -> v2.2.1
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

git pull  

package gopkg.in/dancannon/gorethink.v2/encoding: exit status 1
# cd /opt/gocode/src/gopkg.in/fatih/pool.v2; git pull --ff-only
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

git pull  

package gopkg.in/fatih/pool.v2: exit status 1

 

On Friday, October 14, 2016 at 6:17:14 PM UTC+2, gurp...@gmail.com wrote:
>
>  cd $GOPATH/src/github.com/mattn/go-sqlite3; git pull --ff-only origin 
> master
>
> Add `origin master` suffix to the command suggested by the error. (master 
> or otherwise)
>
> The error occurs because the repo got a new branch since your last go get.
>
> On Saturday, May 28, 2016 at 11:12:27 PM UTC+5:30, Tong Sun wrote:
>>
>> How to fix the "You are not currently on a branch" error for `go get`?
>>
>> $ go get -u github.com/mattn/go-sqlite3
>> # cd .../src/github.com/mattn/go-sqlite3; git pull --ff-only
>> From https://github.com/mattn/go-sqlite3
>>  * [new branch]  gh-pages   -> origin/gh-pages
>>bbd33c0..38ee283  master -> origin/master
>>  * [new branch]  systemlib  -> origin/systemlib
>>  * [new tag] v1.0.0 -> v1.0.0
>>  * [new tag] v1.1.0 -> v1.1.0
>> You are not currently on a branch.
>> Please specify which branch you want to merge with.
>> See git-pull(1) for details.
>>
>> git pull  
>>
>> package github.com/mattn/go-sqlite3: exit status 1
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Re: go get: You are not currently on a branch

2016-10-12 Thread Thomas Modeneis
Hi Oir,
The main problem seems to be related to go get believe me or not.
I manage to get this right after I deleted  $GOPATH/pkg/* 
and  $GOPATH/src/golang.org

Thanks


On Wednesday, October 12, 2016 at 3:51:07 PM UTC+2, ohir wrote:
>
> Dnia 2016-10-12, o godz. 02:37:16 
> Thomas Modeneis <thomas@gmail.com > napisaƂ(a): 
>
> > You are not currently on a branch. Please specify which 
> > branch you want to merge with. See git-pull(1) for details. 
>
> This is common to freshmen to get a checkout of some tag then 
> forget they did it. This is a root cause of update fails. 
>
> > Oh this is one of the problems that is really time consuming. I'm not 
> sure 
> > if this is related, but I've never had this kind of problems before 
> +1.7. 
>
> Do you use any half-baked 'pkg versioning' tool? 
> If you did not checked by hand, such tool may be a culprit. 
>
> > Any ideas ? 
>
> Better education? 
>
> OK. Go get docs should have a warning box in red flash: 
>
> [ Either learn about git usage or never ever tinker within 
>  $GOPATH/src/github.com. If go get -u barks on you with 'You are 
> not currently on a branch' message, cd into the mentioned directory and 
> do: 
> 'git checkout master' there. After that you may do 'go get -u' again. 
> Rinse 
> and repeat. ] 
>
>
> -- 
> Wojciech S. Czarnecki 
>^oo^ OHIR-RIPE 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: go get: You are not currently on a branch

2016-10-12 Thread Thomas Modeneis
Oh this is one of the problems that is really time consuming. I'm not sure 
if this is related, but I've never had this kind of problems before +1.7.

@Dave, I've tried your "quick-fix" but no luck ...

$ go get google.golang.org/grpc
# cd /opt/gocode/src/golang.org/x/net; git pull --ff-only
You are not currently on a branch. Please specify which
branch you want to merge with. See git-pull(1) for details.

git pull  

package golang.org/x/net/http2: exit status 1
package golang.org/x/net/trace: cannot find package 
"golang.org/x/net/trace" in any of:
/usr/local/go/src/golang.org/x/net/trace (from $GOROOT)
/opt/gocode/src/golang.org/x/net/trace (from $GOPATH)
package golang.org/x/net/http2/hpack: cannot find package 
"golang.org/x/net/http2/hpack" in any of:
/usr/local/go/src/golang.org/x/net/http2/hpack (from $GOROOT)
/opt/gocode/src/golang.org/x/net/http2/hpack (from $GOPATH)


On Saturday, May 28, 2016 at 7:42:27 PM UTC+2, Tong Sun wrote:
>
> How to fix the "You are not currently on a branch" error for `go get`?
>
> $ go get -u github.com/mattn/go-sqlite3
> # cd .../src/github.com/mattn/go-sqlite3; git pull --ff-only
> From https://github.com/mattn/go-sqlite3
>  * [new branch]  gh-pages   -> origin/gh-pages
>bbd33c0..38ee283  master -> origin/master
>  * [new branch]  systemlib  -> origin/systemlib
>  * [new tag] v1.0.0 -> v1.0.0
>  * [new tag] v1.1.0 -> v1.1.0
> You are not currently on a branch.
> Please specify which branch you want to merge with.
> See git-pull(1) for details.
>
> git pull  
>
> package github.com/mattn/go-sqlite3: exit status 1
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Re: go get: You are not currently on a branch

2016-10-12 Thread Thomas Modeneis
This issue is all over the web, people are having problems multiple times:

http://stackoverflow.com/questions/33064343/go-get-git-error-on-all-sources-but-golang-org
https://github.com/tools/godep/issues/60
https://github.com/golang/go/issues/6042
http://stackoverflow.com/questions/30188499/how-to-do-go-get-on-a-specific-tag-of-a-github-repository
https://github.com/gopherjs/gopherjs/issues/439
https://github.com/grpc/grpc-go/issues/807
https://github.com/kataras/iris/issues/245

Quote from one of the issues, people seem frustrated with Go package 
management:
"tamird  commented on Aug 1 

Yes, welcome to Go's terrible package management."

Any ideas ?

Cheers.

On Saturday, May 28, 2016 at 7:42:27 PM UTC+2, Tong Sun wrote:
>
> How to fix the "You are not currently on a branch" error for `go get`?
>
> $ go get -u github.com/mattn/go-sqlite3
> # cd .../src/github.com/mattn/go-sqlite3; git pull --ff-only
> From https://github.com/mattn/go-sqlite3
>  * [new branch]  gh-pages   -> origin/gh-pages
>bbd33c0..38ee283  master -> origin/master
>  * [new branch]  systemlib  -> origin/systemlib
>  * [new tag] v1.0.0 -> v1.0.0
>  * [new tag] v1.1.0 -> v1.1.0
> You are not currently on a branch.
> Please specify which branch you want to merge with.
> See git-pull(1) for details.
>
> git pull  
>
> package github.com/mattn/go-sqlite3: exit status 1
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.