Commit Graph

184 Commits

Author SHA1 Message Date
Wenzel Jakob 35c82c7250 changelog for version 2.2.4 & features targeted for 2.3.0 2018-09-11 10:41:30 +02:00
luzpaz 4b874616b2 Misc. typos (#1384)
Found via `codespell`
2018-05-06 10:54:10 -03:00
Wenzel Jakob f5f6618962 updated changelog for v2.2.3 2018-04-29 15:47:13 +02:00
Lori A. Burns bdbe8d0bde Enforces intel icpc >= 2017, fixes #1121 (#1363) 2018-04-29 13:48:25 +02:00
Wenzel Jakob 2d0507db43 added v2.2.2 changelog 2018-02-07 11:05:41 +01:00
Wenzel Jakob 6d19036cb2
support docstrings in enum::value() (#1160) 2017-11-16 22:24:36 +01:00
Ted Drain 0a0758ce3a Added write only property functions for issue #1142 (#1144)
py::class_<T>'s `def_property` and `def_property_static` can now take a
`nullptr` as the getter to allow a write-only property to be established
(mirroring Python's `property()` built-in when `None` is given for the
getter).

This also updates properties to use the new nullptr constructor internally.
2017-11-07 12:35:27 -04:00
Dean Moldovan 56613945ae Use semi-constexpr signatures on MSVC
MSCV does not allow `&typeid(T)` in constexpr contexts, but the string
part of the type signature can still be constexpr. In order to avoid
`typeid` as long as possible, `descr` is modified to collect type
information as template parameters instead of constexpr `typeid`.
The actual `std::type_info` pointers are only collected in the end,
as a `constexpr` (gcc/clang) or regular (MSVC) function call.

Not only does it significantly reduce binary size on MSVC, gcc/clang
benefit a little bit as well, since they can skip some intermediate
`std::type_info*` arrays.
2017-09-16 12:02:49 +02:00
Wenzel Jakob f94d759881 updated changelog for v2.2.1 release 2017-09-14 08:51:30 +02:00
Dean Moldovan 27680302dd Update changelog for v2.2.1 release 2017-09-13 19:04:25 +02:00
Dean Moldovan 2b4477eb65 Make TypeErrors more informative when an optional header is missing
E.g. trying to convert a `list` to a `std::vector<int>` without
including <pybind11/stl.h> will now raise an error with a note that
suggests checking the headers.

The note is only appended if `std::` is found in the function
signature. This should only be the case when a header is missing.
E.g. when stl.h is included, the signature would contain `List[int]`
instead of `std::vector<int>` while using stl_bind.h would produce
something like `MyVector`. Similarly for `std::map`/`Dict`, `complex`,
`std::function`/`Callable`, etc.

There's a possibility for false positives, but it's pretty low.
2017-09-12 08:06:46 +02:00
Dean Moldovan 953d2422b3 Fix a reference leak in the number converter (#1078)
Fixes #1075.

`PyNumber_Float()` and `PyNumber_Long()` return new references.
2017-09-10 16:53:02 +02:00
Dean Moldovan 7b1de1e551 Fix nullptr dereference when loading an external-only module_local type 2017-09-10 12:28:03 +02:00
Dean Moldovan 3c4933cb50 Fix STL casters for containers with proxies (regression)
To avoid an ODR violation in the test suite while testing
both `stl.h` and `std_bind.h` with `std::vector<bool>`,
the `py::bind_vector<std::vector<bool>>` test is moved to
the secondary module (which does not include `stl.h`).
2017-09-10 12:25:10 +02:00
Dean Moldovan b0a0e4a23c Fix compilation with Clang on host GCC < 5 (old libstdc++) 2017-09-08 12:48:14 +02:00
Dean Moldovan 00b8f3655d Relax py::pickle() get/set type check
Fixes #1061.

`T` and `const T &` are compatible types.
2017-09-06 15:20:52 +02:00
Dean Moldovan 7939f4b3fe Fix application of keep_alive policy to constructors (regression) 2017-09-06 10:21:11 +02:00
Wenzel Jakob 8cf091a41f updated version flags for next version 2017-08-31 14:01:08 +02:00
Wenzel Jakob 2a5a5ec0a4 updated changelog.rst with release date 2017-08-31 13:58:24 +02:00
Dean Moldovan 4c5404421f Update changelog and upgrade guide
[skip ci]
2017-08-30 22:48:39 +02:00
Bruce Merry 37de2da9dd Access C++ hash functions from Python and vice versa (#1034)
There are two separate additions:

1. `py::hash(obj)` is equivalent to the Python `hash(obj)`.
2. `.def(hash(py::self))` registers the hash function defined by
   `std::hash<T>` as the Python hash function.
2017-08-30 14:22:00 +02:00
Dean Moldovan 1e5a7da30d Add py::pickle() adaptor for safer __getstate__/__setstate__ bindings
This is analogous to `py::init()` vs `__init__` + placement-new.
`py::pickle()` reuses most of the implementation details of `py::init()`.
2017-08-30 11:11:38 +02:00
Wenzel Jakob a1041190c8 mention PR #1037 in changelog 2017-08-28 16:35:32 +02:00
Henry Schreiner 8b40505575 Utility for redirecting C++ streams to Python (#1009) 2017-08-25 02:12:43 +02:00
Matthias Hochsteger e8b5074187 Fix wrong link in changelog 2017-08-23 12:06:30 -04:00
Wenzel Jakob b12a9d67c6 mention PR #1015 in changelog 2017-08-23 16:30:56 +02:00
Dean Moldovan 1fb9df601c Add upgrade guide to the documentation
[skip ci]
2017-08-21 01:12:45 +02:00
Dean Moldovan db46a89d96 Update changelog for v2.2.0
[skip ci]
2017-08-21 00:59:48 +02:00
Wenzel Jakob db200955b9 changelog for v2.1.1 2017-04-07 02:08:29 +02:00
Wenzel Jakob 0d92938f74 minor style fix 2017-03-22 22:52:29 +01:00
Wenzel Jakob d405b1b3a4 updated version information for v2.2 development 2017-03-22 22:20:07 +01:00
Wenzel Jakob 62e5fef09e Changelog for v2.1.0 (#759) 2017-03-22 22:07:45 +01:00
Wenzel Jakob a9730be73c use -x flag to strip shared libraries on OSX (fixes #595) 2017-01-06 14:20:26 +01:00
Wenzel Jakob f8dafe908e changelog for 2.0.1 release 2017-01-04 15:09:49 +01:00
Wenzel Jakob e33ef9c20d v2.0.0 release 2017-01-01 13:56:37 +01:00
Wenzel Jakob ed52f4664c updated changelog 2016-12-26 13:54:50 +01:00
Wenzel Jakob 3c79671112 a few more minor v2.0.0-rc1 related changes 2016-12-23 16:19:36 +01:00
Wenzel Jakob d3549d6027 added changelog for v2.0.0-rc1 2016-12-23 16:01:19 +01:00
Dean Moldovan e18bc02fc9 Add default and converting constructors for all concrete Python types
* Deprecate the `py::object::str()` member function since `py::str(obj)`
  is now equivalent and preferred

* Make `py::repr()` a free function

* Make sure obj.cast<T>() works as expected when T is a Python type

`obj.cast<T>()` should be the same as `T(obj)`, i.e. it should convert
the given object to a different Python type. However, `obj.cast<T>()`
usually calls `type_caster::load()` which only checks the type without
doing any actual conversion. That causes a very unexpected `cast_error`.
This commit makes it so that `obj.cast<T>()` and `T(obj)` are the same
when T is a Python type.

* Simplify pytypes converting constructor implementation

It's not necessary to maintain a full set of converting constructors
and assignment operators + const& and &&. A single converting const&
constructor will work and there is no impact on binary size. On the
other hand, the conversion functions can be significantly simplified.
2016-11-17 08:55:42 +01:00
Ivan Smirnov 44a69f78cf std::experimental::optional (#475)
* Add type caster for std::experimental::optional

* Add tests for std::experimental::optional

* Support both <optional> / <experimental/optional>

* Mention std{::experimental,}::optional in the docs
2016-11-03 13:42:46 +01:00
Dean Moldovan 03f627ebb1 Make reference(_internal) the default return value policy for properties (#473)
* Make reference(_internal) the default return value policy for properties

Before this, all `def_property*` functions used `automatic` as their
default return value policy. This commit makes it so that:

 * Non-static properties use `reference_interal` by default, thus
   matching `def_readonly` and `def_readwrite`.

 * Static properties use `reference` by default, thus matching
   `def_readonly_static` and `def_readwrite_static`.

In case `cpp_function` is passed to any `def_property*`, its policy will
be used instead of any defaults. User-defined arguments in `extras`
still have top priority and will override both the default policies and
the ones from `cpp_function`.

Resolves #436.

* Almost always use return_value_policy::move for rvalues

For functions which return rvalues or rvalue references, the only viable
return value policies are `copy` and `move`. `reference(_internal)` and
`take_ownership` would take the address of a temporary which is always
an error.

This commit prevents possible user errors by overriding the bad rvalue
policies with `move`. Besides `move`, only `copy` is allowed, and only
if it's explicitly selected by the user.

This is also a necessary safety feature to support the new default
return value policies for properties: `reference(_internal)`.
2016-11-01 11:44:57 +01:00
Dean Moldovan 5d28dd1194 Support std::shared_ptr holder type out of the box
With this there is no more need for manual user declarations like
`PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)`. Existing ones
will still compile without error -- they will just be ignored silently.

Resolves #446.
2016-10-20 16:19:58 +02:00
Dean Moldovan 242b146a51 Extend attribute and item accessor interface using object_api 2016-09-23 02:00:01 +02:00
Dean Moldovan 625bd48a91 Document calling function with keyword arguments from C++ 2016-09-06 16:41:50 +02:00
Ivan Smirnov 606160ed68 Update the changelog re: generalized iterators 2016-08-24 23:32:13 +01:00
Ivan Smirnov 6715736936 Add handle::repr() method 2016-08-14 13:43:31 +01:00
Ivan Smirnov bccbc10a65 Update changelog and authors 2016-08-13 21:17:26 +01:00
Wenzel Jakob a720a6046e updated changelog with v1.8.1, updated release instructions 2016-07-12 18:03:17 +02:00
Wenzel Jakob c47d498c35 fix rare GC issue during type creation (fixes #277) 2016-07-11 23:41:15 +02:00
Wenzel Jakob 58ec1caa9b updated README and changelog 2016-07-11 23:39:39 +02:00
Wenzel Jakob e6b2f75949 updated changelog 2016-07-10 10:54:46 +02:00
Wenzel Jakob f88af0c127 clarification on static properties (fixes #248) 2016-06-22 13:52:31 +02:00
Wenzel Jakob f950215046 note about semver policy 2016-06-14 15:02:07 +02:00
Wenzel Jakob 1cbe7ef2ac changelog update 2016-06-14 14:55:10 +02:00
Wenzel Jakob 38d8b8cfe2 don't allow registering a class twice (fixes #218) 2016-05-31 09:53:28 +02:00
Wenzel Jakob 86d825f330 Redesigned virtual call mechanism and user-facing syntax (breaking change!)
Sergey Lyskov pointed out that the trampoline mechanism used to override
virtual methods from within Python caused unnecessary overheads when
instantiating the original (i.e. non-extended) class.

This commit removes this inefficiency, but some syntax changes were
needed to achieve this. Projects using this features will need to make a
few changes:

In particular, the example below shows the old syntax to instantiate a
class with a trampoline:

class_<TrampolineClass>("MyClass")
    .alias<MyClass>()
    ....

This is what should be used now:

class_<MyClass, std::unique_ptr<MyClass, TrampolineClass>("MyClass")
    ....

Importantly, the trampoline class is now specified as the *third*
argument to the class_ template, and the alias<..>() call is gone. The
second argument with the unique pointer is simply the default holder
type used by pybind11.
2016-05-26 13:36:24 +02:00
Wenzel Jakob 3f200fab22 don't implicitly convert doubles to ints 2016-05-17 15:35:29 +02:00
Wenzel Jakob 9e0a0568fe transparent conversion of dense and sparse Eigen types 2016-05-05 21:44:29 +02:00
Wenzel Jakob 163ac2ef53 changelog updates 2016-05-03 14:16:18 +02:00
Wenzel Jakob c4d7ccd8b0 started working on v1.8 2016-04-30 22:00:44 +02:00
Wenzel Jakob e70b2abb6d preparing for v1.7 release 2016-04-30 22:00:24 +02:00
Wenzel Jakob dd7ec34d50 documentation updates 2016-04-29 10:06:24 +02:00
Wenzel Jakob e84f557edf documentation improvements 2016-04-26 23:48:55 +02:00
Wenzel Jakob 1ac22e35e3 changelog updates 2016-04-25 23:25:40 +02:00
Wenzel Jakob bb79d7bdc0 preparing for version 1.5 release 2016-04-21 12:23:20 +02:00
Wenzel Jakob dbe43ffcce completed implicit type casters for reference_wrapper 2016-04-21 12:21:14 +02:00
Wenzel Jakob c79dbe425d FAQ improvements 2016-04-18 10:53:38 +02:00
Wenzel Jakob b2b44a9af8 fix for virtual dispatch on newly created threads 2016-04-15 17:59:53 +02:00
Wenzel Jakob b282595bba convenience wrapper for constructing iterators (fixes #142) 2016-04-14 00:23:37 +02:00
Wenzel Jakob d7efa4ff7b return best representation of polymorphic types (fixes #105) 2016-04-13 13:51:33 +02:00
Wenzel Jakob 1c329aab5a pickling support (fixes #144) 2016-04-13 02:58:56 +02:00
Wenzel Jakob 2c5d560640 changelog update 2016-04-11 18:46:11 +02:00
Wenzel Jakob 33c2a0494f minor documentation update 2016-04-07 09:06:49 +02:00
Wenzel Jakob 0e6ca5916e version 1.4 2016-04-07 08:49:37 +02:00
Wenzel Jakob 3411673fbf updated changelog 2016-04-06 17:55:41 +02:00
Wenzel Jakob 4e455dde0b updated changelog, added build directory to gitignore file 2016-03-09 16:50:40 +01:00
Wenzel Jakob 81dfd2c51f Working type casters for wide strings and wide characters 2016-03-08 20:48:07 +01:00
Wenzel Jakob d2385e8fc6 ready for version 1.3 2016-03-08 18:09:50 +01:00
Wenzel Jakob cf2b87aa5e changelog update 2016-02-22 17:32:44 +01:00
Wenzel Jakob 8ed2808239 pybind11, version 1.2 2016-02-07 17:32:37 +01:00
Wenzel Jakob cd4e6ae3f0 updated changelog 2016-01-29 11:48:40 +01:00
Wenzel Jakob 61587164ed example on manually vectorizing numpy code (closes #27) 2016-01-18 22:38:52 +01:00
Wenzel Jakob 48548ea4a5 general cleanup of the codebase
- new pybind11::base<> attribute to indicate a subclass relationship
- unified infrastructure for parsing variadic arguments in class_ and cpp_function
- use 'handle' and 'object' more consistently everywhere
2016-01-17 22:31:15 +01:00
Wenzel Jakob 1ae77fe4d3 added a changelog file and version defines 2016-01-17 22:31:15 +01:00