A mini implementation of python library.

Overview

minipy

author = RQDYSGN

date = 2021.10.11

version = 0.2

1. 简介

​ 基于python3.7环境,通过py原生库和leetcode上的一些习题构建的超小型py lib。

2. 环境

  • Python 3.7

2. 结构

${project_name}/
|-- __init__.py
|-- __pycache__
|   `-- __init__.cpython-37.pyc
|-- main.py
|-- minipy
|   |-- __init__.py
|   |-- __pycache__
|   |   |-- __init__.cpython-37.pyc
|   |   `-- math.cpython-37.pyc
|   |-- geometry
|   |   |-- Hypersphere.py
|   |   |-- Point.py
|   |   |-- __init__.py
|   |   `-- __pycache__
|   |       |-- Hypersphere.cpython-37.pyc
|   |       |-- Point.cpython-37.pyc
|   |       `-- __init__.cpython-37.pyc
|   |-- graph
|   |   |-- __init__.py
|   |   |-- __pycache__
|   |   |   |-- __init__.cpython-37.pyc
|   |   |   `-- graph.cpython-37.pyc
|   |   `-- graph.py
|   |-- list
|   |   |-- __init__.py
|   |   |-- __pycache__
|   |   |   |-- __init__.cpython-37.pyc
|   |   |   `-- numList.cpython-37.pyc
|   |   `-- numList.py
|   |-- math.py
|   `-- string
|       |-- SingleString.py
|       |-- __init__.py
|       `-- __pycache__
|           |-- SingleString.cpython-37.pyc
|           `-- __init__.cpython-37.pyc
|-- setup.py
`-- test_py
    |-- __init__.py
    |-- __pycache__
    |   |-- __init__.cpython-37.pyc
    |   |-- test_geometry.cpython-37-pytest-5.4.1.pyc
    |   |-- test_graph.cpython-37-pytest-5.4.1.pyc
    |   |-- test_list.cpython-37-pytest-5.4.1.pyc
    |   `-- test_string.cpython-37-pytest-5.4.1.pyc
    |-- test_geometry.py
    |-- test_graph.py
    |-- test_list.py
    `-- test_string.py

3. 测试

需提前安装pytest。基于pytest的简单测试,操作步骤:

cd leetcode/
py.test test_py/

Out:

image-20211009202706499

4. 安装&卸载

install:

cd leetcode/
pip install dist/minipy-0.1.tar.gz

uninstall:

pip uninstall minipy

5. 使用

An simple example:

import minipy as py

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    adj = [
        [0, 2, 6, 4],
        [float("inf"), 0, 3, float("inf")],
        [7, float("inf"), 0, 1],
        [5, float("inf"), 12, 0]
    ]
    g = py.graph(adj)
    g.print_adjacency()
    gg = py.shortestPathClass(g)
    print(gg.shortestPath(1, 0))
    print(gg.shortestCost(1, 0))
    print()

    numList1 = py.numList([])
    numList2 = py.numList([1, 1, 1, 1, 1])
    numList3 = py.numList([1, 2, 3, 4, 5])
    numList4 = py.numList([5, 1, 3, 2, 4])
    print(numList1.findMiddleIndex())
    print(numList1.minimumDifference(2))
    print(numList1.insertionSort())
    print(numList1.mergeSort())
    print(numList2.findMiddleIndex())
    print(numList2.minimumDifference(2))
    print(numList2.insertionSort())
    print(numList2.mergeSort())
    print(numList3.findMiddleIndex())
    print(numList3.minimumDifference(2))
    print(numList3.insertionSort())
    print(numList3.mergeSort())
    print(numList4.findMiddleIndex())
    print(numList4.minimumDifference(2))
    print(numList4.insertionSort())
    print(numList4.mergeSort())
    print()

    s = ""
    ss = py.SingleString(s)
    print('max power is', ss.maxPower())
    print()

    point1 = tuple([1, 2])
    point2 = tuple([-2, -2])
    p1 = py.Point2D(point1)
    p2 = py.Point2D(point2)
    print("p1 coordinate is", p1.coordinate)
    print("p2 coordinate is", p2.coordinate)
    print("Distance between p1 and p2 is", py.distance(p1, p2))

Out:

Graph:
0	2	6	4	
∞	0	3	∞	
7	∞	0	1	
5	∞	12	0	
[1, 2, 3, 0]
9

-1
-1
[]
[]
2
0
[1, 1, 1, 1, 1]
[1, 1, 1, 1, 1]
-1
1
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
2
1
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]

max power is 0

p1 coordinate is (1, 2)
p2 coordinate is (-2, -2)
Distance between p1 and p2 is 5.0
Owner
RQDYGSN
RQDYGSN
wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.

wxPython Project Phoenix Introduction Welcome to wxPython's Project Phoenix! Phoenix is the improved next-generation wxPython, "better, stronger, fast

1.9k Jan 07, 2023
Cython plugin for Lark, reimplementing the LALR parser & lexer for better performance

Lark-Cython Cython plugin for Lark, reimplementing the LALR parser & lexer for better performance on CPython. Install: pip install lark-cython Usage:

Lark - Parsing Library & Toolkit 31 Dec 26, 2022
CPython Extension Module Support for Flit

CPython Extension Module Support for Flit This is a PEP 517 build backend piggybacking (and hacking) Flit to support building C extensions. Mostly a p

Tzu-ping Chung 8 May 24, 2022
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.

pythonnet - Python.NET Python.NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) a

3.5k Jan 06, 2023
A faster and highly-compatible implementation of the Python programming language. The code here is out of date, please follow our blog

Pyston is a faster and highly-compatible implementation of the Python programming language. Version 2 is currently closed source, but you can find the

4.9k Dec 21, 2022
x2 - a miniminalistic, open-source language created by iiPython

x2 is a miniminalistic, open-source language created by iiPython, inspired by x86 assembly and batch. It is a high-level programming language with low-level, easy-to-remember syntaxes, similar to x86

Benjamin 3 Jul 29, 2022
Core Python libraries ported to MicroPython

This is a repository of libraries designed to be useful for writing MicroPython applications.

MicroPython 1.8k Jan 07, 2023
A faster and highly-compatible implementation of the Python programming language.

Pyston Pyston is a fork of CPython 3.8.8 with additional optimizations for performance. It is targeted at large real-world applications such as web se

2.3k Jan 09, 2023
The Stackless Python programming language

This is Python version 3.7.0 alpha 4+ Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 20

Stackless Python 891 Jan 03, 2023
MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems

The MicroPython project This is the MicroPython project, which aims to put an implementation of Python 3.x on microcontrollers and small embedded syst

MicroPython 15.7k Dec 31, 2022
Grumpy is a Python to Go source code transcompiler and runtime.

Grumpy: Go running Python Overview Grumpy is a Python to Go source code transcompiler and runtime that is intended to be a near drop-in replacement fo

Google 10.6k Dec 24, 2022
A mini implementation of python library.

minipy author = RQDYSGN date = 2021.10.11 version = 0.2 1. 简介 基于python3.7环境,通过py原生库和leetcode上的一些习题构建的超小型py lib。 2. 环境 Python 3.7 2. 结构 ${project_name}

RQDYGSN 2 Oct 26, 2021
Rust syntax and lexical analyzer implemented in Python.

Rust Scanner Rust syntax and lexical analyzer implemented in Python. This project was made for the Programming Languages class at ESPOL (SOFG1009). Me

Joangie Marquez 0 Jul 03, 2022
Pyjion - A JIT for Python based upon CoreCLR

Pyjion Designing a JIT API for CPython A note on development Development has moved to https://github.com/tonybaloney/Pyjion FAQ What are the goals of

Microsoft 1.6k Dec 30, 2022
An implementation of Python in Common Lisp

CLPython - an implementation of Python in Common Lisp CLPython is an open-source implementation of Python written in Common Lisp. With CLPython you ca

Willem Broekema 339 Jan 04, 2023
DO NOT USE. Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime.

IronPython 3 IronPython3 is NOT ready for use yet. There is still much that needs to be done to support Python 3.x. We are working on it, albeit slowl

IronLanguages 2k Dec 30, 2022
x86-64 assembler embedded in Python

Portable Efficient Assembly Code-generator in Higher-level Python (PeachPy) PeachPy is a Python framework for writing high-performance assembly kernel

Marat Dukhan 1.7k Jan 03, 2023
The Python programming language

This is Python version 3.10.0 alpha 5 Copyright (c) 2001-2021 Python Software Foundation. All rights reserved. See the end of this file for further co

Python 49.7k Dec 30, 2022