Sfoglia il codice sorgente

Add references in README

Tal Liron 5 anni fa
parent
commit
41a3473b28
3 ha cambiato i file con 13 aggiunte e 4 eliminazioni
  1. 5 0
      .pydevproject
  2. 3 0
      README.md
  3. 5 4
      primitive.go

+ 5 - 0
.pydevproject

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?><pydev_project>
+    <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+    <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python interpreter</pydev_property>
+</pydev_project>

+ 3 - 0
README.md

@@ -92,3 +92,6 @@ References
 * [go-python](https://github.com/sbinet/go-python) is a similar and more mature project for Python
   2.
 * [goPy](https://github.com/qur/gopy) is a much older project for Python 2.
+* [gopy](https://github.com/go-python/gopy) generates Python wrappers for Go functions.
+* [setuptools-golang](https://github.com/asottile/setuptools-golang) allows you to include Go
+  libraries in Python packages.

+ 5 - 4
primitive.go

@@ -156,11 +156,11 @@ func (self *Reference) IsUnicode() bool {
 }
 
 func (self *Reference) ToString() (string, error) {
-	if utf8string := C.PyUnicode_AsUTF8String(self.Object); utf8string != nil {
-		defer C.Py_DecRef(utf8string)
+	if utf8stringBytes := C.PyUnicode_AsUTF8String(self.Object); utf8stringBytes != nil {
+		defer C.Py_DecRef(utf8stringBytes)
 
-		if string_ := C.PyBytes_AsString(utf8string); string_ != nil {
-			return C.GoString(string_), nil
+		if utf8string := C.PyBytes_AsString(utf8stringBytes); utf8string != nil {
+			return C.GoString(utf8string), nil
 		} else {
 			return "", GetError()
 		}
@@ -245,6 +245,7 @@ func NewListRaw(size int) (*Reference, error) {
 }
 
 func (self *Reference) IsList() bool {
+	// More efficient to use the flag
 	return self.Type().HasFlag(C.Py_TPFLAGS_LIST_SUBCLASS)
 }