Commit Graph

3732 Commits

Author SHA1 Message Date
David Hewitt 79c7149d52 pyo3-build-config: new crate to re-use build.rs across crates 2021-05-20 09:03:33 +01:00
David Hewitt a109640850 pyfn: deprecate name argument 2021-05-20 08:54:29 +01:00
mejrs dac260403a pyany documentation 2021-05-19 23:46:11 +02:00
David Hewitt 8bb72a711a
Merge pull request #1613 from davidhewitt/inline-callback
callback: add `#[inline]` to callback conversion code
2021-05-19 20:57:42 +01:00
Georg Brandl 95d7fa27be
Merge pull request #1617 from birkenfeld/simple_args_bench
pyo3_benchmarks: add a benchmark for the "only simple args" case
2021-05-19 11:44:21 +02:00
Georg Brandl 473474cae7 pyo3_benchmarks: add a benchmark for the "only simple args" case
This is the case that will be helped by fastcall support,
so add it first as a baseline.
2021-05-19 08:17:33 +02:00
Georg Brandl ea0fdb4928
Merge pull request #1615 from birkenfeld/new_clippy 2021-05-17 14:58:34 +02:00
Georg Brandl d9beb1c11f
Merge pull request #1614 from birkenfeld/double_clippy
Fix clippy ignore directives
2021-05-17 10:40:11 +02:00
Georg Brandl 4539e3524b Fix new-in-nightly clippy warning
Example:

error: used `assert_eq!` with a literal bool
   --> src/types/sequence.rs:675:9
    |
675 |         assert_eq!(empty_seq.is_empty().unwrap(), true);
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `assert!(..)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bool_assert_comparison
2021-05-17 09:59:40 +02:00
Georg Brandl 698dbe038e Fix clippy ignore directives 2021-05-17 09:45:34 +02:00
David Hewitt 51ba541a18
Merge pull request #1609 from davidhewitt/bench-gil
benches: add bench_gil
2021-05-17 08:27:14 +01:00
David Hewitt cb2b70bb8d callback: add #[inline] to callback conversion code 2021-05-17 08:14:05 +01:00
David Hewitt 6f63f63c21
Merge pull request #1612 from birkenfeld/pyfn_noargs
pyfunction: use METH_NOARGS for no-argument functions
2021-05-17 07:49:21 +01:00
David Hewitt 0cc77c77b2 benches: add bench_gil 2021-05-17 07:37:03 +01:00
Georg Brandl f6e4399f26 pyfunction: use METH_NOARGS for no-argument functions
As suggested in #1607.

If I ran the benchmarks correctly, this shaves only about 5ns from
the noargs case.  But since it's relatively easy to do...
2021-05-17 07:53:24 +02:00
Georg Brandl 1c557a52cd
Merge pull request #1611 from TheGhostHuCodes/fix-doc-typos
Fix typos in Architecture and Contributing docs
2021-05-17 07:06:20 +02:00
Yung-Jin (Joey) Hu edb3d0d03b Fix typos in Architecture and Contributing docs 2021-05-16 19:49:23 -07:00
David Hewitt c4b19c7e7c
Merge pull request #1604 from 1tgr/shrink
Improve compilation times for projects using PyO3
2021-05-16 07:18:33 +01:00
David Hewitt 85f1055db8
Merge pull request #1605 from goodbyekansas/cross-compile-wasm
Add support for cross compilation for wasm/wasi
2021-05-16 07:15:02 +01:00
David Hewitt c48e5b08ea
Merge pull request #1608 from alex/opt-no-args
Reduce function calling overhead by ~25% in ReferencePool::update_counts:
2021-05-15 21:11:08 +01:00
Alex Gaynor 56973d762b Reduce function calling overhead by ~25% in ReferencePool::update_counts:
1) Place both increfs and decrefs behind a single mutex, rather than two. Even uncontended mutexes aren't free to acquire.
2) Keep a dirty tracking bool to avoid acquiring any mutexes at all in the common case of no modifications (because everything happened with the GIL held)
2021-05-15 13:19:51 -04:00
Tim Robinson 50352f9137 Apply review suggestions 2021-05-15 10:34:34 +01:00
Simon Rainerson b0f7145f9c Add support for cross compilation for wasm/wasi
When using rust after this commit
1a491e2304
the target family for wasm targets is now set to "wasm". Also fix the
assumption that OsStrExt lives inside std::os::unix for all non-windows
targets.
2021-05-14 14:38:28 +02:00
Tim Robinson 735a9a1156 Update for_each_proto_slot for consistency 2021-05-13 17:32:59 +01:00
Tim Robinson c803033f5e Add to CHANGELOG 2021-05-13 13:17:56 +01:00
Tim Robinson c3b935f06c Reduce size of compiled code for class initialization 2021-05-13 13:08:58 +01:00
Tim Robinson 95636f1ba7 Reduce size of compiled code for methods 2021-05-13 13:06:38 +01:00
Tim Robinson 32dc93e389 Shorten typical argument extraction checks 2021-05-13 13:06:38 +01:00
mejrs 1ae3d87973
More docs+examples (freelist, pyany, pymodule, puthon::check_signals) (#1600)
* expanded freelist docs

* added check_signals doc example

* added doc examples for pyany methods

* doc examples for pymodule + deprecate add_wrapped

* fixed tabs+whitespace...

* stronger wording on running signal handler code

Co-authored-by: Georg Brandl <georg@python.org>

* fix keyboardinterrupt spelling

Co-authored-by: Georg Brandl <georg@python.org>

* remove semicolon

Co-authored-by: Georg Brandl <georg@python.org>

* add space

Co-authored-by: Georg Brandl <georg@python.org>

* add space

Co-authored-by: Georg Brandl <georg@python.org>

* added suggested changes

* fixed doctest

* fixed triple backslash

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>

* spacing inside struct

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>

* use ? rather than unwrap in doc examples

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>

* remove use of "we", "us", "you" from docs

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>

* add that freelist shouldnt be impl'd by users

* added suggested changes

Co-authored-by: Georg Brandl <georg@python.org>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-05-12 07:32:46 +01:00
David Hewitt cc68f4a021
Merge pull request #1567 from davidhewitt/attribute-tidy
macros: support `#[pyo3(name = "...")]` in pyfunction
2021-05-11 08:14:56 +01:00
David Hewitt 70f9d198e5 docs: add docs for `#[pyo3(name = "...")]` 2021-05-07 22:43:57 +01:00
David Hewitt 48e98818cf [review] kngwyu 2021-05-07 22:35:52 +01:00
David Hewitt 4d46abde73 macros: support `#[pyo3(name = "...")]` 2021-05-07 22:35:52 +01:00
David Hewitt 4613b3dd7e
Merge pull request #1596 from davidhewitt/remove-pytypeinfo-layout
type_object: remove layout and base type from PyTypeInfo
2021-05-07 22:32:24 +01:00
David Hewitt eb251a2f22
Merge pull request #1599 from PyO3/davidhewitt-patch-1-1
guide: update CI job names
2021-05-07 22:28:18 +01:00
David Hewitt 926b2a7325 guide: update CI job names 2021-05-07 08:30:49 +01:00
messense 272d014518
Merge pull request #1598 from davidhewitt/rust-1.52
rust: updates for rust 1.52
2021-05-07 09:01:38 +08:00
David Hewitt defd09c166 rust: updates for rust 1.52 2021-05-06 23:18:34 +01:00
David Hewitt 4edc7c6dc5
Merge pull request #1597 from m-ou-se/wrap-pyfunction-as-closure
Expand wrap_pyfunction!() to a closure to improve deduction.
2021-05-06 22:57:55 +01:00
Mara Bos d33c5010c7 Add test for wrap_pyfunction!() deduction. 2021-05-06 16:05:17 +02:00
Mara Bos 5289ce0eda Expand wrap_pyfunction!() to a closure.
The change to wrap_pyfunction!() in #1143 makes it impossible to
implement `context.add_wrapped(wrap_pyfunction!(something))` in
`inline-python`.
`context` does not carry the GIL lifetime, which causes type deduction
trouble now that `wrap_pyfunction` results in a generic function.

```
error[E0308]: mismatched types
  --> examples/rust-fn.rs:12:4
   |
12 |     c.add_wrapped(wrap_pyfunction!(rust_print));
   |       ^^^^^^^^^^^ one type is more general than the other
   |
   = note: expected enum `Result<&pyo3::types::PyCFunction, _>`
              found enum `Result<&pyo3::types::PyCFunction, _>`
```

By re-wrapping the function as a closure, we trigger 'closure signature
deduction' when passing `wrap_pyfunction!()` as an argument to a
function: Rustc will deduce the signature of the closure from the
function that closure is passed to. This way, the generic arguments can
be deduced in more contexts, fixing the problem.
2021-05-06 16:03:05 +02:00
messense dfee3474f8
Merge pull request #1590 from mejrs/docsrs
docsrs feature
2021-05-05 20:42:49 +08:00
messense 136b7d400f Also run gh-pages deploy on release 2021-05-05 16:39:46 +08:00
messense 8a89d04ee9 Remove docs job from CI workflow 2021-05-05 16:35:18 +08:00
messense 3402e72427 Run guide workflow on pull request 2021-05-05 11:27:12 +08:00
messense 620c2730f5 Build docs of main branch with docsrs feature 2021-05-05 11:26:34 +08:00
David Hewitt 350e7b2be7
Merge pull request #1591 from davidhewitt/inherit-exceptions
pyclass: support extending Exception types
2021-05-04 23:04:10 +01:00
mejrs dd26566d0c added package.metadata.docs.rs information 2021-05-04 23:25:09 +02:00
David Hewitt d81abe8344 pyclass: support extending Exception types 2021-05-04 22:00:22 +01:00
David Hewitt 7536554ceb type_object: remove layout and base type from PyTypeInfo 2021-05-04 21:39:42 +01:00