Examples of PyLong


Examples of org.python.core.PyLong

        }


        final private void load_long() {
            String line = file.readlineNoNl();
            push(new PyLong(line.substring(0, line.length()-1)));
        }
View Full Code Here

Examples of org.python.core.PyLong

        }

        private void load_bin_long(int length) {
            int longLength = read_binint(length);
            if (longLength == 0) {
                push(new PyLong(BigInteger.ZERO));
                return;
            }
            String s = file.read(longLength);
            byte[] bytes = new byte[s.length()];
            // Write to the byte array in reverse order: pickle orders
            // by little endian whereas BigInteger orders by big
            // endian
            int n = s.length() - 1;
            for (int i = 0; i < s.length(); i++, n--) {
                char c = s.charAt(i);
                if(c >= 128) {
                    bytes[n] = (byte)(c - 256);
                } else {
                    bytes[n] = (byte)c;
                }
            }
            BigInteger bigint = new BigInteger(bytes);
            push(new PyLong(bigint));
        }
View Full Code Here

Examples of org.python.core.PyLong

            case Types.SMALLINT:
                obj = Py.newInteger(set.getInt(col));
                break;

            case Types.BIGINT:
                obj = new PyLong(set.getLong(col));
                break;

            case Types.FLOAT:
            case Types.REAL:
                obj = Py.newFloat(set.getFloat(col));
View Full Code Here

Examples of org.python.core.PyLong

            case Types.SMALLINT:
                obj = Py.newInteger(stmt.getInt(col));
                break;

            case Types.BIGINT:
                obj = new PyLong(stmt.getLong(col));
                break;

            case Types.FLOAT:
            case Types.REAL:
                obj = Py.newFloat(stmt.getFloat(col));
View Full Code Here

Examples of org.python.core.PyLong

            ZipEntry zipEntry = zipEntries.nextElement();
            String name = zipEntry.getName().replace('/', File.separatorChar);

            PyObject __file__ = new PyString(archive + File.separator + name);
            PyObject compress = Py.newInteger(zipEntry.getMethod());
            PyObject data_size = new PyLong(zipEntry.getCompressedSize());
            PyObject file_size = new PyLong(zipEntry.getSize());
            // file_offset is a CPython optimization; it's used to seek directly to the
            // file when reading it later. Jython doesn't do this nor is the offset
            // available
            PyObject file_offset = Py.newInteger(-1);
            PyObject time = new PyInteger(epochToDosTime(zipEntry.getTime()));
            PyObject date = new PyInteger(epochToDosDate(zipEntry.getTime()));
            PyObject crc = new PyLong(zipEntry.getCrc());

            PyTuple entry = new PyTuple(__file__, compress, data_size, file_size, file_offset,
                                        time, date, crc);
            files.__setitem__(new PyString(name), entry);
        }
View Full Code Here

Examples of org.python.core.PyLong

                    return num;
                }
            } else if (num.getInternalN() instanceof PyLong) {
                BigInteger v = ((PyLong)num.getInternalN()).getValue();
                if (v.compareTo(BigInteger.ZERO) == 1) {
                    num.setN(new PyLong(v.negate()));
                    return num;
                }
            } else if (num.getInternalN() instanceof PyFloat) {
                double v = ((PyFloat)num.getInternalN()).getValue();
                if (v >= 0) {
View Full Code Here

Examples of org.python.core.PyLong

     */
    @ExposedMethod(defaults = "null")
    final void Random_seed(PyObject seed) {
        long n;
        if (seed == null) {
            seed = new PyLong(System.currentTimeMillis());
        }
        if (seed instanceof PyLong) {
            PyLong max = new PyLong(Long.MAX_VALUE);
            n = seed.__mod__(max).asLong();
        } else if (seed instanceof PyInteger) {
            n = seed.asLong();
        } else {
            n = seed.hashCode();
View Full Code Here

Examples of org.python.core.PyLong

        return new PyFloat(ret);
    }
   
    @ExposedMethod
    final PyLong Random_getrandbits(int k) {
        return new PyLong(new BigInteger(k, javaRandom));
    }
View Full Code Here

Examples of org.python.core.PyLong

    add(new NumberToPyInteger(Byte.class));
    add(new NumberToPyInteger(Short.class));
    add(new ClassAdapter(Long.class) {

      public PyObject adapt(Object o) {
        return new PyLong(((Number) o).longValue());
      }

    });
    add(new ClassAdapter(Boolean.class) {
View Full Code Here

Examples of org.python.core.PyLong

                    .append(".")
                    .append(valueName)
                    .toString();
            }
            PyTuple tuple = new PyTuple(new PyString(metricName),
                new PyTuple(new PyLong(timestamp), new PyString(value)));
            metrics.add(tuple);
            if(metrics.size() >= batchSize) {
                writeMetrics();
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.