summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOmer Katz <omer.drow@gmail.com>2019-03-08 10:53:45 +0200
committerOmer Katz <omer.drow@gmail.com>2019-03-08 10:53:45 +0200
commitf455ff6a69a7759ef36f0e82d6f83bac731f29ab (patch)
tree24a164246481ef4094e8063676bffa6056588199 /src
parentf6f921326acf52eef5671ffedff764ba25146b2b (diff)
downloadpy-amqp-rust-serialization.tar.gz
Create list with capacity.rust-serialization
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 25f66d1..4ad1e9d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -11,8 +11,8 @@ use pyo3::{IntoPy, Py};
use std::io::{self, Cursor, Read, Seek, SeekFrom};
use pyo3::import_exception;
-// Since this module is being currently imported we assume the GIL is acquired.
-// If it isn't, this module is the least of our problems
+// Since these modules are being currently imported we assume the GIL is acquired.
+// If they aren't, these modules is the least of our problems
lazy_static! {
static ref DATETIME_MODULE: &'static PyModule =
{ unsafe { Python::assume_gil_acquired().import("datetime").unwrap() } };
@@ -218,10 +218,9 @@ impl<'deserializer_l> AMQPDeserializer<'deserializer_l> {
}
fn deserialize(&mut self) -> PyResult<(&'deserializer_l PyList, u64)> {
- // TODO: Figure out why
- // let values = PyList::with_capacity(*self.py, self.format.len());
- // crashes
- let values = PyList::empty(*self.py);
+ let none = &self.py.None();
+ let initial = vec![none; self.format.len()];
+ let values = PyList::new(*self.py, initial);
for p in self.format.chars() {
match p {