Skip to content

Commit d4aa9a8

Browse files
committed
mark C++ parts as GIL-free compatible
1 parent 301d1b2 commit d4aa9a8

File tree

8 files changed

+46
-13
lines changed

8 files changed

+46
-13
lines changed

lib/area.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of pyosmium. (https://osmcode.org/pyosmium/)
44
*
5-
* Copyright (C) 2024 Sarah Hoffmann <[email protected]> and others.
5+
* Copyright (C) 2025 Sarah Hoffmann <[email protected]> and others.
66
* For a full list of authors see the git log.
77
*/
88

@@ -127,7 +127,11 @@ class AreaManager : public pyosmium::BaseHandler
127127

128128
} // namespace
129129

130+
#ifdef Py_GIL_DISABLED
131+
PYBIND11_MODULE(area, m, py::mod_gil_not_used())
132+
#else
130133
PYBIND11_MODULE(area, m)
134+
#endif
131135
{
132136
py::class_<AreaManagerSecondPassHandler, pyosmium::BaseHandler>(m,
133137
"AreaManagerSecondPassHandler");

lib/filter.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of pyosmium. (https://osmcode.org/pyosmium/)
44
*
5-
* Copyright (C) 2024 Sarah Hoffmann <[email protected]> and others.
5+
* Copyright (C) 2025 Sarah Hoffmann <[email protected]> and others.
66
* For a full list of authors see the git log.
77
*/
88
#include <pybind11/pybind11.h>
@@ -12,7 +12,12 @@
1212

1313
namespace py = pybind11;
1414

15-
PYBIND11_MODULE(filter, m) {
15+
#ifdef Py_GIL_DISABLED
16+
PYBIND11_MODULE(filter, m, py::mod_gil_not_used())
17+
#else
18+
PYBIND11_MODULE(filter, m)
19+
#endif
20+
{
1621
pyosmium::init_empty_tag_filter(m);
1722
pyosmium::init_key_filter(m);
1823
pyosmium::init_tag_filter(m);

lib/geom.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of pyosmium. (https://osmcode.org/pyosmium/)
44
*
5-
* Copyright (C) 2024 Sarah Hoffmann <[email protected]> and others.
5+
* Copyright (C) 2025 Sarah Hoffmann <[email protected]> and others.
66
* For a full list of authors see the git log.
77
*/
88
#include <pybind11/pybind11.h>
@@ -75,7 +75,11 @@ void make_factory_class(py::module_ &m, char const *name)
7575

7676
} // namespace
7777

78+
#ifdef Py_GIL_DISABLED
79+
PYBIND11_MODULE(geom, m, py::mod_gil_not_used())
80+
#else
7881
PYBIND11_MODULE(geom, m)
82+
#endif
7983
{
8084
py::enum_<og::use_nodes>(m, "use_nodes")
8185
.value("UNIQUE", og::use_nodes::unique)

lib/index.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of pyosmium. (https://osmcode.org/pyosmium/)
44
*
5-
* Copyright (C) 2024 Sarah Hoffmann <[email protected]> and others.
5+
* Copyright (C) 2025 Sarah Hoffmann <[email protected]> and others.
66
* For a full list of authors see the git log.
77
*/
88
#include <pybind11/pybind11.h>
@@ -14,7 +14,11 @@
1414

1515
namespace py = pybind11;
1616

17+
#ifdef Py_GIL_DISABLED
18+
PYBIND11_MODULE(index, m, py::mod_gil_not_used())
19+
#else
1720
PYBIND11_MODULE(index, m)
21+
#endif
1822
{
1923
using LocationTable =
2024
osmium::index::map::Map<osmium::unsigned_object_id_type, osmium::Location>;

lib/io.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of pyosmium. (https://osmcode.org/pyosmium/)
44
*
5-
* Copyright (C) 2024 Sarah Hoffmann <[email protected]> and others.
5+
* Copyright (C) 2025 Sarah Hoffmann <[email protected]> and others.
66
* For a full list of authors see the git log.
77
*/
88
#include <pybind11/pybind11.h>
@@ -25,7 +25,11 @@ class FileBuffer : public osmium::io::File
2525
} // namespace
2626

2727

28+
#ifdef Py_GIL_DISABLED
29+
PYBIND11_MODULE(io, m, py::mod_gil_not_used())
30+
#else
2831
PYBIND11_MODULE(io, m)
32+
#endif
2933
{
3034
py::class_<osmium::io::File>(m, "File")
3135
.def(py::init<std::string>())

lib/osm.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of pyosmium. (https://osmcode.org/pyosmium/)
44
*
5-
* Copyright (C) 2024 Sarah Hoffmann <[email protected]> and others.
5+
* Copyright (C) 2025 Sarah Hoffmann <[email protected]> and others.
66
* For a full list of authors see the git log.
77
*/
88
#include <pybind11/pybind11.h>
@@ -151,8 +151,12 @@ py::class_<COSMObject> make_osm_object_class(py::module_ &m, char const *class_n
151151

152152
} // namespace
153153

154-
155-
PYBIND11_MODULE(_osm, m) {
154+
#ifdef Py_GIL_DISABLED
155+
PYBIND11_MODULE(_osm, m, py::mod_gil_not_used())
156+
#else
157+
PYBIND11_MODULE(_osm, m)
158+
#endif
159+
{
156160
py::enum_<osmium::osm_entity_bits::type>(m, "osm_entity_bits")
157161
.value("NOTHING", osmium::osm_entity_bits::nothing)
158162
.value("NODE", osmium::osm_entity_bits::node)

lib/osmium.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of pyosmium. (https://osmcode.org/pyosmium/)
44
*
5-
* Copyright (C) 2024 Sarah Hoffmann <[email protected]> and others.
5+
* Copyright (C) 2025 Sarah Hoffmann <[email protected]> and others.
66
* For a full list of authors see the git log.
77
*/
88
#include <pybind11/pybind11.h>
@@ -72,8 +72,12 @@ void pyosmium::apply(osmium::io::Reader &reader, pyosmium::BaseHandler &handler)
7272
handler.flush();
7373
}
7474

75-
76-
PYBIND11_MODULE(_osmium, m) {
75+
#ifdef Py_GIL_DISABLED
76+
PYBIND11_MODULE(_osmium, m, py::mod_gil_not_used())
77+
#else
78+
PYBIND11_MODULE(_osmium, m)
79+
#endif
80+
{
7781
py::register_exception<osmium::invalid_location>(m, "InvalidLocationError");
7882
py::register_exception_translator([](std::exception_ptr p) {
7983
try {

lib/replication.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*
33
* This file is part of pyosmium. (https://osmcode.org/pyosmium/)
44
*
5-
* Copyright (C) 2024 Sarah Hoffmann <[email protected]> and others.
5+
* Copyright (C) 2025 Sarah Hoffmann <[email protected]> and others.
66
* For a full list of authors see the git log.
77
*/
88
#include <pybind11/pybind11.h>
@@ -31,7 +31,11 @@ struct LastChangeHandler : public osmium::handler::Handler
3131

3232
} // namespace
3333

34+
#ifdef Py_GIL_DISABLED
35+
PYBIND11_MODULE(_replication, m, py::mod_gil_not_used())
36+
#else
3437
PYBIND11_MODULE(_replication, m)
38+
#endif
3539
{
3640
m.def("newest_change_from_file", [](char const *filename)
3741
{

0 commit comments

Comments
 (0)