use python like objects in rust, such as list
, for now.
have the simplicity
and performance
together.
be happy.
``rust
// the crate name is 'python-objects'
// because there is another crate out there with
pythonname
// but the lib.rs (library crate of this crate) its called
python`
// so you can import like this
extern crate python;
// use everything from python use python::*;
fn main() { // create a new python list from a string let mut pythonlist = List::fromstring(String::from("123123")); // since rust doesnt have function overloading // we are stuck with different names // but i think its better because its more explicit // append some values pythonlist.appendint(123); pythonlist.appendfloat(123.123); pythonlist.appendfloat(123.123); pythonlist.appendfloat(123.123); pythonlist.appendstring(String::from("asdasd")); // append a rust string pythonlist.appendlist( List::fromstring("rust's string".tostring())); // append a python string pythonlist.appendpstring( String::fromstring( String::from("python string")));
// note the python-like print
// print to stdout
print(&python_list);
// and len
// print length of list
print(len(&python_list));
} ```
output ```shell
['1', '2', '3', '1', '2', '3', 123, 123.123, 123.123, 123.123, 'asdasd', ['a', 'n', 'd', 'r', 'e', 'w'], 'python string']
13 ```
as you can see the list contains char
, float (f32)
, integer (i32)
, a rust string
, another python list
, and a python string
this is just bare bones
and experimental
, more features will come soon. stay still!
why not. because python concepts are very cool, but python is slow..
so what if we could use python objects in rust and have the same experience as in python (almost) ?
and things are getting much better. rust has zero-cost abstractions
, meaning that every struct and trait will be deleted at compile time
and they will be gone at runtime
.
so we are getting python objects in rust with performance
and simplity
.
check TODO.md
fork the repo on github
clone your repo to local
shell
git clone https://github.com/<your-username>/rust-python-objects
make your branch
shell
git checkout -b <username>-<branch-name>
note: the branch name can be whatever you want, but would be more suggestive to be a username and feature name
make some changes in the source code
add + commit + push changes to your forked repo
add
shell
git add .
commit
shell
git commit -m 'created the best feature every. feels so good to contribute to open source'
push
shell
git push github <your-branch-name>
go to github to your forked repo and send a pull request
wait for approval :)
note for the user and developer
right now this project is very minimal, it will grow, the idea just came to my mind some days ago (on 21.02.2022) and the first implementation was done at 4 AM (23.02.2022) with some adrenaline.
so for now dont expect too much of this crate
peace to you!